From 1e52e1ff518987092cfe94bc5c9c4479ed535019 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 11 Jul 2010 11:30:27 +0100 Subject: When cleaning up queries, q->data is free()d. Even if it turns out to be the "struct irc" containing all data belonging to a session. Sanitise memory management a little bit here. (There are some memory leaks in here too that need to be fixed at some point.) --- query.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'query.c') diff --git a/query.c b/query.c index b60669f7..67382b79 100644 --- a/query.c +++ b/query.c @@ -30,7 +30,8 @@ static void query_display( irc_t *irc, query_t *q ); static query_t *query_default( irc_t *irc ); query_t *query_add( irc_t *irc, struct im_connection *ic, char *question, - query_callback yes, query_callback no, void *data ) + query_callback yes, query_callback no, query_callback free, + void *data ) { query_t *q = g_new0( query_t, 1 ); @@ -38,6 +39,7 @@ query_t *query_add( irc_t *irc, struct im_connection *ic, char *question, q->question = g_strdup( question ); q->yes = yes; q->no = no; + q->free = free; q->data = data; if( strchr( irc->umode, 'b' ) != NULL ) @@ -93,7 +95,8 @@ void query_del( irc_t *irc, query_t *q ) } g_free( q->question ); - if( q->data ) g_free( q->data ); /* Memory leak... */ + if( q->free && q->data ) + q->free( q->data ); g_free( q ); } -- cgit v1.2.3