changeset 26687:a25d09019b9b

xmlCtxtGetLastError may return NULL, especially with other misbehaving libraries in our address space. References #8136.
author Paul Aurich <paul@darkrain42.org>
date Sun, 26 Apr 2009 01:42:34 +0000
parents 17379effc417
children ef1616b50974
files libpurple/protocols/jabber/parser.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/parser.c	Sun Apr 26 00:30:02 2009 +0000
+++ b/libpurple/protocols/jabber/parser.c	Sun Apr 26 01:42:34 2009 +0000
@@ -232,8 +232,17 @@
 		xmlParseChunk(js->context, "", 0, 0);
 	} else if ((ret = xmlParseChunk(js->context, buf, len, 0)) != XML_ERR_OK) {
 		xmlError *err = xmlCtxtGetLastError(js->context);
+		/*
+		 * libxml2 uses a global setting to determine whether or not to store
+		 * warnings.  Other libraries may set this, which causes err to be
+		 * NULL. See #8136 for details.
+		 */
+		xmlErrorLevel level = XML_ERR_WARNING;
 
-		switch (err->level) {
+		if (err)
+			level = err->level;
+
+		switch (level) {
 			case XML_ERR_NONE:
 				purple_debug_info("jabber", "xmlParseChunk returned info %i\n", ret);
 				break;