diff libpurple/protocols/msn/slplink.c @ 30509:287fc4ac2bd9

Add and remove an extra ref per MsnMessage when saving it in a slpmsg, to fix a possible use-after-free from valgrind. Also, don't traverse slpmsg->msgs twice.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 24 May 2010 06:27:03 +0000
parents e432507151d1
children 3f7f469ee1d0 2bc54dfae627
line wrap: on
line diff
--- a/libpurple/protocols/msn/slplink.c	Sun May 23 21:45:19 2010 +0000
+++ b/libpurple/protocols/msn/slplink.c	Mon May 24 06:27:03 2010 +0000
@@ -322,7 +322,7 @@
 #endif
 
 	slpmsg->msgs =
-		g_list_append(slpmsg->msgs, msg);
+		g_list_append(slpmsg->msgs, msn_message_ref(msg));
 	msn_slplink_send_msg(slplink, msg);
 
 	if ((slpmsg->flags == 0x20 || slpmsg->flags == 0x1000020 ||
@@ -381,6 +381,8 @@
 			}
 		}
 	}
+
+	msn_message_unref(msg);
 }
 
 /* We have received the message nak. */
@@ -394,6 +396,7 @@
 	msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
 
 	slpmsg->msgs = g_list_remove(slpmsg->msgs, msg);
+	msn_message_unref(msg);
 }
 
 static void