Fix some memory problems in search

This commit is contained in:
Sebastian Ramacher 2010-12-21 14:40:05 +01:00
parent d56c6da26e
commit 12e6f8281c

View file

@ -1854,7 +1854,7 @@ search(void* parameter)
static char* search_item; static char* search_item;
static int direction; static int direction;
static int next_page = 0; static int next_page = 0;
gchar* old_query; gchar* old_query = NULL;
int page_counter; int page_counter;
GList* results = NULL; GList* results = NULL;
@ -1933,6 +1933,9 @@ search(void* parameter)
} }
} }
g_free(argument->data);
g_free(argument);
/* draw results */ /* draw results */
if(results) if(results)
{ {
@ -2295,8 +2298,11 @@ sc_search(Argument* argument)
g_static_mutex_lock(&(Zathura.Lock.search_lock)); g_static_mutex_lock(&(Zathura.Lock.search_lock));
} }
Argument* newarg = g_malloc0(sizeof(Argument));
newarg->n = argument->n;
newarg->data = argument->data ? g_strdup(argument->data) : NULL;
Zathura.Thread.search_thread_running = TRUE; Zathura.Thread.search_thread_running = TRUE;
Zathura.Thread.search_thread = g_thread_create(search, (gpointer) argument, TRUE, NULL); Zathura.Thread.search_thread = g_thread_create(search, (gpointer) newarg, TRUE, NULL);
g_static_mutex_unlock(&(Zathura.Lock.search_lock)); g_static_mutex_unlock(&(Zathura.Lock.search_lock));
} }
@ -4009,8 +4015,10 @@ scmd_search(gchar* input, Argument* argument)
if(!input || !strlen(input)) if(!input || !strlen(input))
return TRUE; return TRUE;
argument->data = g_strdup(input); Argument* newarg = g_malloc0(sizeof(argument));
sc_search(argument); newarg->n = argument->n;
newarg->data = g_strdup(input);
sc_search(newarg);
return TRUE; return TRUE;
} }