diff options
author | Max Kellermann <max@duempel.org> | 2008-11-18 21:51:07 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-11-18 21:51:07 +0100 |
commit | c985ba258d95fb267e35a96e92eb6f8461b83668 (patch) | |
tree | d89e7ebe6ad6343f389c3aeb5fc1019d24fc080f | |
parent | cd1663f4ce44fcb20bae7782bb71e96876333125 (diff) | |
download | mpd-c985ba258d95fb267e35a96e92eb6f8461b83668.tar.gz mpd-c985ba258d95fb267e35a96e92eb6f8461b83668.tar.xz mpd-c985ba258d95fb267e35a96e92eb6f8461b83668.zip |
screen_browser: check if filelist is set
When calling browser_change_directory() before a filelist was set,
ncmpc would crash due to a NULL pointer dereference. This scenario is
not possible currently, since the open() method allocates the
filelist.
-rw-r--r-- | src/screen_browser.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/screen_browser.c b/src/screen_browser.c index a9ed37991..bcf749ed7 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -201,15 +201,20 @@ browser_change_directory(struct screen_browser *browser, mpdclient_t *c, } else return false; - old_path = g_strdup(browser->filelist->path); + if (browser->filelist != NULL) { + old_path = g_strdup(browser->filelist->path); + filelist_free(browser->filelist); + } else + old_path = NULL; - filelist_free(browser->filelist); browser->filelist = mpdclient_filelist_get(c, path); #ifndef NCMPC_MINI sync_highlights(c, browser->filelist); #endif - idx = filelist_find_directory(browser->filelist, old_path); + idx = old_path != NULL + ? filelist_find_directory(browser->filelist, old_path) + : -1; g_free(old_path); list_window_reset(browser->lw); |