libpurple/protocols/msn/oim.c

changeset 35265
77664079d0f0
parent 34935
686fa55b0deb
parent 35203
68d6df7dc69c
child 35499
c4c5e0a670b1
--- a/libpurple/protocols/msn/oim.c	Mon Jan 20 07:39:26 2014 +0530
+++ b/libpurple/protocols/msn/oim.c	Mon Jan 20 00:02:17 2014 -0800
@@ -361,11 +361,12 @@
 			if (faultcode) {
 				char *faultcode_str = purple_xmlnode_get_data(faultcode);
 
-				if (g_str_equal(faultcode_str, "q0:AuthenticationFailed")) {
+				if (faultcode_str && g_str_equal(faultcode_str, "q0:AuthenticationFailed")) {
 					PurpleXmlNode *challengeNode = purple_xmlnode_get_child(faultNode,
 						"detail/LockKeyChallenge");
+					char *challenge = NULL;
 
-					if (challengeNode == NULL) {
+					if (challengeNode == NULL || (challenge = purple_xmlnode_get_data(challengeNode)) == NULL) {
 						if (oim->challenge) {
 							g_free(oim->challenge);
 							oim->challenge = NULL;
@@ -383,7 +384,6 @@
 					} else {
 						char buf[33];
 
-						char *challenge = purple_xmlnode_get_data(challengeNode);
 						msn_handle_chl(challenge, buf);
 
 						g_free(oim->challenge);
@@ -399,22 +399,23 @@
 					}
 				} else {
 					/* Report the error */
-					const char *str_reason;
-
-					if (g_str_equal(faultcode_str, "q0:SystemUnavailable")) {
-						str_reason = _("Message was not sent because the system is "
-						               "unavailable. This normally happens when the "
-						               "user is blocked or does not exist.");
+					const char *str_reason = NULL;
 
-					} else if (g_str_equal(faultcode_str, "q0:SenderThrottleLimitExceeded")) {
-						str_reason = _("Message was not sent because messages "
-						               "are being sent too quickly.");
+					if (faultcode_str) {
+						if (g_str_equal(faultcode_str, "q0:SystemUnavailable")) {
+							str_reason = _("Message was not sent because the system is "
+							               "unavailable. This normally happens when the "
+							               "user is blocked or does not exist.");
+						} else if (g_str_equal(faultcode_str, "q0:SenderThrottleLimitExceeded")) {
+							str_reason = _("Message was not sent because messages "
+							               "are being sent too quickly.");
+						} else if (g_str_equal(faultcode_str, "q0:InvalidContent")) {
+							str_reason = _("Message was not sent because an unknown "
+							               "encoding error occurred.");
+						}
+					}
 
-					} else if (g_str_equal(faultcode_str, "q0:InvalidContent")) {
-						str_reason = _("Message was not sent because an unknown "
-						               "encoding error occurred.");
-
-					} else {
+					if (str_reason == NULL) {
 						str_reason = _("Message was not sent because an unknown "
 						               "error occurred.");
 					}
@@ -823,10 +824,10 @@
 		char *unread = purple_xmlnode_get_data(iu_node);
 		const char *passports[2] = { msn_user_get_passport(session->user) };
 		const char *urls[2] = { session->passport_info.mail_url };
-		int count = atoi(unread);
+		int count;
 
 		/* XXX/khc: pretty sure this is wrong */
-		if (count > 0)
+		if (unread && (count = atoi(unread)) > 0)
 			purple_notify_emails(purple_account_get_connection(session->account), count, FALSE, NULL,
 				NULL, passports, urls, NULL, NULL);
 		g_free(unread);

mercurial