Skip to content

Commit

Permalink
TagListPage: fix nullptr dereference when adding "[All]"
Browse files Browse the repository at this point in the history
Commit 9f5a075 caused a regression because two variables were mixed
up: the `text` must not be nullptr, or else Utf8ToLocale() crashes.

Closes #77
  • Loading branch information
MaxKellermann committed Oct 15, 2020
1 parent 8e9c42d commit 8be12f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ncmpc 0.41 - not yet released
* new main loop (copying code from MPD, replacing boost::asio)
* library page: fix crash bug
* lyrics: remove the "lyricwiki" plugin because the site is gone

ncmpc 0.40 - (2020-10-07)
Expand Down
6 changes: 4 additions & 2 deletions src/TagListPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ add_query(struct mpdclient *c, const TagFilter &filter,
return;

const char *text = value;
if (value == nullptr)
value = filter.empty() ? "?" : filter.front().second.c_str();
if (text == nullptr)
/* adding the special "[All]" entry: show the name of
the previous level in the filter */
text = filter.empty() ? "?" : filter.front().second.c_str();

screen_status_printf(_("Adding \'%s\' to queue"),
Utf8ToLocale(text).c_str());
Expand Down

0 comments on commit 8be12f3

Please sign in to comment.