Code

screen_queue: fix CMD_SCREEN_SWAP with an empty queue
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Fri, 10 Aug 2012 11:21:39 +0000 (13:21 +0200)
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>
Fri, 10 Aug 2012 11:21:39 +0000 (13:21 +0200)
It crashed without this patch.

NEWS
src/screen_queue.c

diff --git a/NEWS b/NEWS
index 59ee50855cc40bc3ed4554be1c1f7d72f3710c03..59c0c84cf8b01366c0614defd5d46b45b751660f 100644 (file)
--- 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)
index 9b67592356bd89796d9922e47cbcddc81dfbaa83..50e70c4a51ddcb3a321db52455cdb3d2f9afc440 100644 (file)
@@ -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: