changeset 14987:dc9ed6c44c48

[gaim-migrate @ 17766] This should prevent a crash when reading a malformed custom emoticon. Also add some debuggering output for when this happens to see if we can figure out the exact scenario. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 17 Nov 2006 04:31:21 +0000
parents 167421cfe7d7
children 41ced1c9ba29
files libgaim/protocols/msn/object.c libgaim/protocols/msn/slp.c libgaim/protocols/msn/slplink.c
diffstat 3 files changed, 14 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/msn/object.c	Fri Nov 17 03:29:45 2006 +0000
+++ b/libgaim/protocols/msn/object.c	Fri Nov 17 04:31:21 2006 +0000
@@ -22,6 +22,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "object.h"
+#include "debug.h"
 
 #define GET_STRING_TAG(field, id) \
 	if ((tag = strstr(str, id "=\"")) != NULL) \
@@ -94,6 +95,7 @@
 	if (obj->creator == NULL || obj->size == 0 || obj->type == 0
 			|| obj->location == NULL || obj->friendly == NULL
 			|| obj->sha1d == NULL || obj->sha1c == NULL) {
+		gaim_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
 		msn_object_destroy(obj);
 		obj = NULL;
 	}
@@ -106,23 +108,12 @@
 {
 	g_return_if_fail(obj != NULL);
 
-	if (obj->creator != NULL)
-		g_free(obj->creator);
-
-	if (obj->location != NULL)
-		g_free(obj->location);
-
-	if (obj->real_location != NULL)
-		g_free(obj->real_location);
-
-	if (obj->friendly != NULL)
-		g_free(obj->friendly);
-
-	if (obj->sha1d != NULL)
-		g_free(obj->sha1d);
-
-	if (obj->sha1c != NULL)
-		g_free(obj->sha1c);
+	g_free(obj->creator);
+	g_free(obj->location);
+	g_free(obj->real_location);
+	g_free(obj->friendly);
+	g_free(obj->sha1d);
+	g_free(obj->sha1c);
 
 	if (obj->local)
 		local_objs = g_list_remove(local_objs, obj);
--- a/libgaim/protocols/msn/slp.c	Fri Nov 17 03:29:45 2006 +0000
+++ b/libgaim/protocols/msn/slp.c	Fri Nov 17 04:31:21 2006 +0000
@@ -819,6 +819,9 @@
 		smile = tokens[tok];
 		obj = msn_object_new_from_string(gaim_url_decode(tokens[tok + 1]));
 
+		if (obj == NULL)
+			break;
+
 		who = msn_object_get_creator(obj);
 		sha1c = msn_object_get_sha1c(obj);
 
--- a/libgaim/protocols/msn/slplink.c	Fri Nov 17 03:29:45 2006 +0000
+++ b/libgaim/protocols/msn/slplink.c	Fri Nov 17 04:31:21 2006 +0000
@@ -147,6 +147,9 @@
 {
 	MsnSlpLink *slplink;
 
+	g_return_val_if_fail(session != NULL, NULL);
+	g_return_val_if_fail(username != NULL, NULL);
+
 	slplink = msn_session_find_slplink(session, username);
 
 	if (slplink == NULL)