diff options
author | Max Kellermann <max@duempel.org> | 2008-09-18 01:15:20 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-18 01:15:20 +0200 |
commit | e54533bd1fad95b149e87918dffca06b0afb5074 (patch) | |
tree | 0f19423193242a63350539812d99120176f3f982 /src/screen_play.c | |
parent | 9de9dfc3a6a8061089eebcc6271b2f13ac43e20b (diff) | |
download | mpd-e54533bd1fad95b149e87918dffca06b0afb5074.tar.gz mpd-e54533bd1fad95b149e87918dffca06b0afb5074.tar.xz mpd-e54533bd1fad95b149e87918dffca06b0afb5074.zip |
screen: check MPD status only if connected
Fix several segmentation faults: when the connection to the MPD server
is lost, there were NULL pointer dereferences because
client->status==NULL. Check before accessing it.
Diffstat (limited to '')
-rw-r--r-- | src/screen_play.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/screen_play.c b/src/screen_play.c index 75462ccf9..c89d150cf 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -85,9 +85,10 @@ list_callback(unsigned idx, int *highlight, void *data) song = playlist_get(&c->playlist, idx); - if( c->song && song->id==c->song->id && !IS_STOPPED(c->status->state) ) { + if (c->song != NULL && song->id == c->song->id && + c->status != NULL && !IS_STOPPED(c->status->state)) *highlight = 1; - } + strfsong(songname, MAX_SONG_LENGTH, LIST_FORMAT, song); return songname; } @@ -99,7 +100,8 @@ center_playing_item(mpdclient_t *c) unsigned offset = lw->selected - lw->start; int idx; - if (!c->song || length<lw->rows || IS_STOPPED(c->status->state)) + if (!c->song || length < lw->rows || + c->status == NULL || IS_STOPPED(c->status->state)) return; /* try to center the song that are playing */ @@ -378,7 +380,8 @@ static void play_update(screen_t *screen, mpdclient_t *c) { /* hide the cursor when mpd are playing and the user are inactive */ - if( options.hide_cursor>0 && c->status->state == MPD_STATUS_STATE_PLAY && + if (options.hide_cursor > 0 && + (c->status != NULL && c->status->state == MPD_STATUS_STATE_PLAY) && time(NULL)-screen->input_timestamp >= options.hide_cursor ) { lw->flags |= LW_HIDE_CURSOR; } else { |