display: fix possible crash if song_columns_list_format was invalid
This commit is contained in:
@@ -274,10 +274,9 @@ void showSongsInColumns(NC::Menu<T> &menu, const MPD::Song &s, HasSongs &screen)
|
|||||||
|
|
||||||
std::string Display::Columns(size_t list_width)
|
std::string Display::Columns(size_t list_width)
|
||||||
{
|
{
|
||||||
if (Config.columns.empty())
|
|
||||||
return "";
|
|
||||||
|
|
||||||
std::string result;
|
std::string result;
|
||||||
|
if (Config.columns.empty())
|
||||||
|
return result;
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int remained_width = list_width;
|
int remained_width = list_width;
|
||||||
@@ -305,12 +304,16 @@ std::string Display::Columns(size_t list_width)
|
|||||||
std::wstring name;
|
std::wstring name;
|
||||||
if (it->name.empty())
|
if (it->name.empty())
|
||||||
{
|
{
|
||||||
for (size_t j = 0; j < it->type.length(); ++j)
|
size_t j = 0;
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
name += toColumnName(it->type[j]);
|
name += toColumnName(it->type[j]);
|
||||||
name += '/';
|
++j;
|
||||||
|
if (j < it->type.length())
|
||||||
|
name += '/';
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
name.resize(name.length()-1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
name = it->name;
|
name = it->name;
|
||||||
|
|||||||
Reference in New Issue
Block a user