Code

screen_browser: added filelist==NULL checks
authorMax Kellermann <max@duempel.org>
Sun, 13 Sep 2009 09:56:42 +0000 (11:56 +0200)
committerMax Kellermann <max@duempel.org>
Sun, 13 Sep 2009 09:56:42 +0000 (11:56 +0200)
If ncmpc could not get a list of files, browser->filelist may be
NULL.  This patch adds two missing checks.

src/screen_browser.c

index 6f29bd70ae04567b776d8f23834c54faf2308c07..5f6e048810ab00a8a6b97efe72b4bb8961bdc7fa 100644 (file)
@@ -124,7 +124,7 @@ browser_lw_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED char **second_c
        filelist_entry_t *entry;
        mpd_InfoEntity *entity;
 
-       if (idx >= filelist_length(fl))
+       if (fl == NULL || idx >= filelist_length(fl))
                return NULL;
 
        entry = filelist_get(fl, idx);
@@ -430,6 +430,9 @@ browser_cmd(struct screen_browser *browser,
 {
        struct mpd_song *song;
 
+       if (browser->filelist == NULL)
+               return false;
+
        switch (cmd) {
        case CMD_PLAY:
                browser_handle_enter(browser, c);