From 89f21b1a1894a6da9e02d83ef3fdaaa8d9a9b59a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Fri, 10 Aug 2012 13:21:39 +0200 Subject: [PATCH] screen_queue: fix CMD_SCREEN_SWAP with an empty queue It crashed without this patch. --- NEWS | 1 + src/screen_queue.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 59ee508..59c0c84 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ ncmpc 0.21 - not yet released * add a chat screen for communication with other clients on the same server * song format: evaluate literal strings as true * fix crash on search screen when disconnected +* screen_queue: fix crash on CMD_SCREEN_SWAP when the queue is empty ncmpc 0.20 - (02/05/2012) diff --git a/src/screen_queue.c b/src/screen_queue.c index 9b67592..50e70c4 100644 --- a/src/screen_queue.c +++ b/src/screen_queue.c @@ -700,7 +700,10 @@ screen_queue_cmd(struct mpdclient *c, command_t cmd) break; #endif case CMD_SCREEN_SWAP: - screen_swap(c, playlist_get(&c->playlist, lw->selected)); + if (playlist_length(&c->playlist) > 0) + screen_swap(c, playlist_get(&c->playlist, lw->selected)); + else + screen_swap(c, NULL); return true; default: -- 2.30.2