For processing mobile OIM's, fix a crash when searching through each part

Mon, 15 Dec 2008 03:00:20 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Mon, 15 Dec 2008 03:00:20 +0000
changeset 25177
d32b730f17c1
parent 25176
10ac048ad6ac
child 25178
ec20ad95148d

For processing mobile OIM's, fix a crash when searching through each part
of the message. There could be no content-type/body if it was unparseable.
Also, skip the first part which is "This is a multipart message... " text.

libpurple/protocols/msn/oim.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/msn/oim.c	Mon Dec 15 02:22:01 2008 +0000
+++ b/libpurple/protocols/msn/oim.c	Mon Dec 15 03:00:20 2008 +0000
@@ -630,13 +630,16 @@
 		                           msn_message_get_attr(message, "boundary"));
 		tokens = g_strsplit(message->body, boundary, 0);
 
-		for (part = tokens; *part != NULL; part++) {
+		/* tokens+1 to skip the "This is a multipart message..." text */
+		for (part = tokens+1; *part != NULL; part++) {
 			MsnMessage *multipart;
+			const char *type;
 			multipart = msn_message_new(MSN_MSG_UNKNOWN);
 			msn_message_parse_payload(multipart, *part, strlen(*part),
 			                          MSG_OIM_LINE_DEM, MSG_OIM_BODY_DEM);
 
-			if (!strcmp(msn_message_get_content_type(multipart), "text/plain")) {
+			type = msn_message_get_content_type(multipart);
+			if (type && !strcmp(type, "text/plain")) {
 				decode_msg = (char *)purple_base64_decode(multipart->body, &body_len);
 				msn_message_destroy(multipart);
 				break;

mercurial