pidgin: adc233c4: Fix a memleak when handling jabber xform...

markdoliner at pidgin.im markdoliner at pidgin.im
Sun Jun 1 16:10:42 EDT 2008


-----------------------------------------------------------------
Revision: adc233c42c586b7fae877a688cd39532eaca23a0
Ancestor: 069f197178d158cdd308687095c14d49d8eee0ed
Author: markdoliner at pidgin.im
Date: 2008-06-01T20:05:06
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/adc233c42c586b7fae877a688cd39532eaca23a0

Modified files:
        libpurple/protocols/jabber/xdata.c

ChangeLog: 

Fix a memleak when handling jabber xforms.  xmlnode_get_data() returns
a string that needs to be freed.  In most places we called
value = xmlnode_get_data() a second time, so the first call wasn't
used or needed.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/xdata.c	24b29e9725ec12a60aa44d58cec57665ac334c75
+++ libpurple/protocols/jabber/xdata.c	fbc7f240e81947bdeaeca264261f02afbb74c133
@@ -232,10 +232,6 @@ void *jabber_x_data_request_with_actions
 		if(!label)
 			label = var;
 
-		if((valuenode = xmlnode_get_child(fn, "value")))
-			value = xmlnode_get_data(valuenode);
-
-
 		if(!strcmp(type, "text-private")) {
 			if((valuenode = xmlnode_get_child(fn, "value")))
 				value = xmlnode_get_data(valuenode);
@@ -333,14 +329,16 @@ void *jabber_x_data_request_with_actions
 			g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_BOOLEAN));
 
 			g_free(value);
-		} else if(!strcmp(type, "fixed") && value) {
+		} else if(!strcmp(type, "fixed")) {
 			if((valuenode = xmlnode_get_child(fn, "value")))
 				value = xmlnode_get_data(valuenode);
 
-			field = purple_request_field_label_new("", value);
-			purple_request_field_group_add_field(group, field);
+			if(value != NULL) {
+				field = purple_request_field_label_new("", value);
+				purple_request_field_group_add_field(group, field);
 
-			g_free(value);
+				g_free(value);
+			}
 		} else if(!strcmp(type, "hidden")) {
 			if((valuenode = xmlnode_get_child(fn, "value")))
 				value = xmlnode_get_data(valuenode);


More information about the Commits mailing list