changeset 24741:fbd1a82247ba

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.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 15 Dec 2008 03:00:20 +0000
parents 7b6037f09baf
children 939d173b68b3
files libpurple/protocols/msn/oim.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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;