pidgin: b2ac0a61: dnssrv: Proper memory management here, w...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Jul 17 16:10:50 EDT 2011


----------------------------------------------------------------------
Revision: b2ac0a617e72d6514db7f373484e3eb94ef34ad0
Parent:   3096beb4b90bc296e9f645ed764086c1d2551a51
Author:   darkrain42 at pidgin.im
Date:     07/17/11 16:08:13
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/b2ac0a617e72d6514db7f373484e3eb94ef34ad0

Changelog: 

dnssrv: Proper memory management here, which stops random crashes elsewhere.

'query' is owned by the query_data, so must not be freed.

Changes against parent 3096beb4b90bc296e9f645ed764086c1d2551a51

  patched  libpurple/dnssrv.c

-------------- next part --------------
============================================================
--- libpurple/dnssrv.c	fefeb89821b8e6b88c999a71aee412bc47339c30
+++ libpurple/dnssrv.c	622e6f4b3745895c90920065efefab2d3e1d2a35
@@ -748,6 +748,7 @@ purple_srv_resolve_account(PurpleAccount
 	if(pipe(in) || pipe(out)) {
 		purple_debug_error("dnssrv", "Could not create pipe\n");
 		g_free(query);
+		g_free(query_data);
 		cb(NULL, 0, extradata);
 		return NULL;
 	}
@@ -755,8 +756,9 @@ purple_srv_resolve_account(PurpleAccount
 	pid = fork();
 	if (pid == -1) {
 		purple_debug_error("dnssrv", "Could not create process!\n");
-		cb(NULL, 0, extradata);
 		g_free(query);
+		g_free(query_data);
+		cb(NULL, 0, extradata);
 		return NULL;
 	}
 
@@ -764,6 +766,7 @@ purple_srv_resolve_account(PurpleAccount
 	if (pid == 0)
 	{
 		g_free(query);
+		g_free(query_data);
 
 		close(out[0]);
 		close(in[1]);
@@ -786,8 +789,6 @@ purple_srv_resolve_account(PurpleAccount
 	query_data->fd_in = in[1];
 	query_data->handle = purple_input_add(out[0], PURPLE_INPUT_READ, resolved, query_data);
 
-	g_free(query);
-
 	return query_data;
 #else
 	if (!initialized) {
@@ -883,6 +884,7 @@ PurpleSrvTxtQueryData *purple_txt_resolv
 	if(pipe(in) || pipe(out)) {
 		purple_debug_error("dnssrv", "Could not create pipe\n");
 		g_free(query);
+		g_free(query_data);
 		cb(NULL, extradata);
 		return NULL;
 	}
@@ -890,8 +892,9 @@ PurpleSrvTxtQueryData *purple_txt_resolv
 	pid = fork();
 	if (pid == -1) {
 		purple_debug_error("dnssrv", "Could not create process!\n");
-		cb(NULL, extradata);
 		g_free(query);
+		g_free(query_data);
+		cb(NULL, extradata);
 		return NULL;
 	}
 
@@ -899,6 +902,7 @@ PurpleSrvTxtQueryData *purple_txt_resolv
 	if (pid == 0)
 	{
 		g_free(query);
+		g_free(query_data);
 
 		close(out[0]);
 		close(in[1]);
@@ -921,8 +925,6 @@ PurpleSrvTxtQueryData *purple_txt_resolv
 	query_data->fd_in = in[1];
 	query_data->handle = purple_input_add(out[0], PURPLE_INPUT_READ, resolved, query_data);
 
-	g_free(query);
-
 	return query_data;
 #else
 	if (!initialized) {


More information about the Commits mailing list