# HG changeset patch # User Mark Doliner # Date 1156716249 0 # Node ID fdf65b672b8779dc277a69b0f6e1df7048449900 # Parent 4e14503b9bac13a0b1b6a08b641f2e46f8e16c0d [gaim-migrate @ 17064] Fix a small memleak committer: Tailor Script diff -r 4e14503b9bac -r fdf65b672b87 libgaim/dnsquery.c --- a/libgaim/dnsquery.c Sun Aug 27 21:36:52 2006 +0000 +++ b/libgaim/dnsquery.c Sun Aug 27 22:04:09 2006 +0000 @@ -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);