Bug fix: Close search window when search in progress
authorColin Clark <colin.clark@cclark.uk>
Tue, 3 Sep 2019 17:00:09 +0000 (18:00 +0100)
committerColin Clark <colin.clark@cclark.uk>
Tue, 3 Sep 2019 17:00:09 +0000 (18:00 +0100)
If the search window is closed when a search is still in progress, there
is a seg. fault.

sd->search_buffer_list is of type MatchFileData not of type FileData.

src/search.c

index ba60e01..00a5790 100644 (file)
@@ -323,6 +323,7 @@ static void search_window_close(SearchData *sd);
 
 static void search_notify_cb(FileData *fd, NotifyType type, gpointer data);
 static void search_start_cb(GtkWidget *widget, gpointer data);
+void mfd_list_free(GList *list);
 
 /*
  *-------------------------------------------------------------------
@@ -735,6 +736,7 @@ static void search_result_collection_from_selection(SearchData *sd)
 {
        CollectWindow *w;
        GList *list;
+DEBUG_0(" ");
 
        list = search_result_selection_list(sd);
        w = collection_window_new(NULL);
@@ -3078,7 +3080,7 @@ static void search_window_destroy_cb(GtkWidget *widget, gpointer data)
 
        search_result_update_idle_cancel(sd);
 
-       filelist_free(sd->search_buffer_list);
+       mfd_list_free(sd->search_buffer_list);
        sd->search_buffer_list = NULL;
 
        search_stop(sd);
@@ -3584,4 +3586,20 @@ static void search_notify_cb(FileData *fd, NotifyType type, gpointer data)
                        break;
                }
 }
+
+void mfd_list_free(GList *list)
+{
+       GList *work;
+
+       work = list;
+       while (work)
+               {
+               MatchFileData *mfd = work->data;
+               file_data_unref((FileData *)mfd->fd);
+               work = work->next;
+               }
+
+       g_list_free(list);
+}
+
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */