From f7e56300cf9c0f570a0979d7f210ccfbd1bdf0be Mon Sep 17 00:00:00 2001 From: unK Date: Sun, 19 Oct 2008 18:48:57 +0200 Subject: [PATCH] check whether info entity returned by mpd is NULL or not --- src/mpdpp.cpp | 15 ++++++++++----- src/ncmpcpp.cpp | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp index 761aec5f..d4b8212d 100644 --- a/src/mpdpp.cpp +++ b/src/mpdpp.cpp @@ -376,11 +376,16 @@ Song MPDConnection::GetCurrentSong() const mpd_sendCurrentSongCommand(itsConnection); mpd_InfoEntity *item = NULL; item = mpd_getNextInfoEntity(itsConnection); - Song result = item->info.song; - item->info.song = 0; - mpd_freeInfoEntity(item); - mpd_finishCommand(itsConnection); - return result; + if (item) + { + Song result = item->info.song; + item->info.song = 0; + mpd_freeInfoEntity(item); + mpd_finishCommand(itsConnection); + return result; + } + else + return Song(); } else return Song(); diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index fe6132ff..934ebb8d 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -103,7 +103,6 @@ time_t timer; int now_playing = -1; int browsed_dir_scroll_begin = 0; -int stats_scroll_begin = 0; int lock_statusbar_delay = -1;