From: <the...@us...> - 2006-08-27 22:04:12
|
Revision: 17064 Author: thekingant Date: 2006-08-27 15:04:09 -0700 (Sun, 27 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=17064&view=rev Log Message: ----------- Fix a small memleak Modified Paths: -------------- trunk/libgaim/dnsquery.c Modified: trunk/libgaim/dnsquery.c =================================================================== --- trunk/libgaim/dnsquery.c 2006-08-27 21:36:52 UTC (rev 17063) +++ trunk/libgaim/dnsquery.c 2006-08-27 22:04:09 UTC (rev 17064) @@ -87,6 +87,21 @@ gaim_debug_info("dnsquery", "IP resolved for %s\n", query_data->hostname); if (query_data->callback != NULL) query_data->callback(hosts, query_data->data, NULL); + else + { + /* + * Callback is a required parameter, but it can get set to + * NULL if we cancel a thread-based DNS lookup. So we need + * to free hosts. + */ + while (hosts != NULL) + { + hosts = g_slist_remove(hosts, hosts->data); + g_free(hosts->data); + hosts = g_slist_remove(hosts, hosts->data); + } + } + gaim_dnsquery_destroy(query_data); } @@ -566,6 +581,7 @@ g_return_val_if_fail(hostname != NULL, NULL); g_return_val_if_fail(port != 0, NULL); + g_return_val_if_fail(callback != NULL, NULL); query_data = g_new(GaimDnsQueryData, 1); query_data->hostname = g_strdup(hostname); @@ -728,6 +744,7 @@ g_return_val_if_fail(hostname != NULL, NULL); g_return_val_if_fail(port != 0, NULL); + g_return_val_if_fail(callback != NULL, NULL); gaim_debug_info("dnsquery", "Performing DNS lookup for %s\n", hostname); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |