From aebc5db0e1634b7dade9c2b31ef4ffb70829e694 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 11 Oct 2009 01:55:36 +0200 Subject: [PATCH] fix segfault that occured if mpd was stopped and window had to be resized we all love null pointer dereferences, don't we? some methods from Song class need assertion guards to deal with that. --- src/status.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/status.cpp b/src/status.cpp index 8652e4f9..23296683 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -347,11 +347,9 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *) { if (myPlaylist->isPlaying()) { - np = Mpd.GetCurrentSong(); - if (!Config.execute_on_song_change.empty()) system(Config.execute_on_song_change.c_str()); - if (Mpd.isPlaying()) + if (Mpd.isPlaying() && !(np = Mpd.GetCurrentSong()).Empty()) WindowTitle(utf_to_locale_cpy(np.toString(Config.song_window_title_format))); if (Config.autocenter_mode && !myPlaylist->Items->isFiltered()) myPlaylist->Items->Highlight(myPlaylist->NowPlaying); @@ -373,11 +371,8 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *) if (((now > past || changed.SongID) && Mpd.isPlaying()) || RedrawStatusbar) { time(&past); - if (np.Empty()) - { - np = Mpd.GetCurrentSong(); + if (np.Empty() && !(np = Mpd.GetCurrentSong()).Empty()) WindowTitle(utf_to_locale_cpy(np.toString(Config.song_window_title_format))); - } if (!np.Empty() && Mpd.isPlaying()) { changed.ElapsedTime = 1;