Code

screen_search: fixed 2 memory leaks
authorMax Kellermann <max@duempel.org>
Fri, 7 Nov 2008 15:14:32 +0000 (16:14 +0100)
committerMax Kellermann <max@duempel.org>
Fri, 7 Nov 2008 15:14:32 +0000 (16:14 +0100)
Free the old pattern before prompting for a new one.  Free the old
filelist object before retrieving the new one.

src/screen_search.c

index 4e2f922ec0caa39c7bf669eedb10857732378a2c..51a8a2966c064f29f873ef2d799f6d9f1ff4468f 100644 (file)
@@ -304,6 +304,7 @@ search_new(mpdclient_t *c)
 {
        search_clear(c, TRUE);
 
+       g_free(pattern);
        pattern = screen_readln(screen.status_window.w,
                                _("Search: "),
                                NULL,
@@ -320,6 +321,11 @@ search_new(mpdclient_t *c)
                return;
        }
 
+       if (browser.filelist != NULL) {
+               filelist_free(browser.filelist);
+               browser.filelist = NULL;
+       }
+
        if (!MPD_VERSION_LT(c, 0, 12, 0))
                browser.filelist = search_advanced_query(pattern, c);