aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen_search.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-21 22:45:08 +0200
committerMax Kellermann <max@duempel.org>2008-09-21 22:45:08 +0200
commit063648606de65ce668c3357ec7b08792ae055219 (patch)
tree4d6804cd6d2379b5d651561049469dee741d649a /src/screen_search.c
parentba91edfee95a6198e2db9804fee9ddfeffa8a199 (diff)
downloadmpd-063648606de65ce668c3357ec7b08792ae055219.tar.gz
mpd-063648606de65ce668c3357ec7b08792ae055219.tar.xz
mpd-063648606de65ce668c3357ec7b08792ae055219.zip
browse: ensure that filelist!=NULL
There are several places where browser.filelist can become NULL. Catch that everywhere and generate an empty filelist in this case.
Diffstat (limited to 'src/screen_search.c')
-rw-r--r--src/screen_search.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/screen_search.c b/src/screen_search.c
index 803772f4f..7dfc58d0f 100644
--- a/src/screen_search.c
+++ b/src/screen_search.c
@@ -168,7 +168,7 @@ search_clear(mpd_unused screen_t *screen, mpdclient_t *c,
if (browser.filelist) {
mpdclient_remove_playlist_callback(c, playlist_changed_callback);
filelist_free(browser.filelist);
- browser.filelist = NULL;
+ browser.filelist = filelist_new(NULL);
}
if (clear_pattern && pattern) {
g_free(pattern);
@@ -186,15 +186,23 @@ filelist_search(mpdclient_t *c, mpd_unused int exact_match, int table,
if (table == SEARCH_ARTIST_TITLE) {
list = mpdclient_filelist_search(c, FALSE, MPD_TABLE_ARTIST,
local_pattern);
+ if (list == NULL)
+ list = filelist_new(NULL);
+
list2 = mpdclient_filelist_search(c, FALSE, MPD_TABLE_TITLE,
local_pattern);
+ if (list2 != NULL) {
+ filelist_move(list, list2);
+ filelist_free(list2);
+ }
- filelist_move(list, list2);
- filelist_free(list2);
filelist_sort(list, compare_filelistentry_format);
list->updated = TRUE;
- } else
+ } else {
list = mpdclient_filelist_search(c, FALSE, table, local_pattern);
+ if (list == NULL)
+ list = filelist_new(NULL);
+ }
return list;
}
@@ -331,6 +339,9 @@ search_new(screen_t *screen, mpdclient_t *c)
mode[options.search_mode].table,
pattern);
+ if (browser.filelist == NULL)
+ browser.filelist = filelist_new(NULL);
+
sync_highlights(c, browser.filelist);
mpdclient_install_playlist_callback(c, playlist_changed_callback);
list_window_check_selected(browser.lw, filelist_length(browser.filelist));