pidgin: d1579a89: xmlParseChunk() never returns less than ...

evands at pidgin.im evands at pidgin.im
Fri Jul 4 12:20:45 EDT 2008


-----------------------------------------------------------------
Revision: d1579a89f3bf59ddffcf9c254872e7c52f2332cd
Ancestor: 1804a14989f21be74dc8231273cf399cd81b45e7
Author: evands at pidgin.im
Date: 2008-07-04T16:07:20
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d1579a89f3bf59ddffcf9c254872e7c52f2332cd

Modified files:
        libpurple/protocols/jabber/parser.c

ChangeLog: 

xmlParseChunk() never returns less than 0. It retusn an error code from 
the xmlParserErrors enum. Success is indicated by XML_ERR_OK, which is
0 and is why this 'error check' coincidentally always passed.

We now properly debug log xmlParseChunk()-returns errors and disconnect
with the XML Parse error if there is a failure. Refinements to follow.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/parser.c	f071b3d656f29726a14c902ff16439a574657565
+++ libpurple/protocols/jabber/parser.c	71536a473b0ca2278d5cc9e4f9e3e12835628c36
@@ -199,12 +199,16 @@ void jabber_parser_process(JabberStream 
 
 void jabber_parser_process(JabberStream *js, const char *buf, int len)
 {
+	int ret;
+
 	if (js->context ==  NULL) {
 		/* libxml inconsistently starts parsing on creating the
 		 * parser, so do a ParseChunk right afterwards to force it. */
 		js->context = xmlCreatePushParserCtxt(&jabber_parser_libxml, js, buf, len, NULL);
 		xmlParseChunk(js->context, "", 0, 0);
-	} else if (xmlParseChunk(js->context, buf, len, 0) < 0) {
+	} else if ((ret = xmlParseChunk(js->context, buf, len, 0)) != XML_ERR_OK) {
+		purple_debug_error("jabber", "xmlParseChunk returned error %i", ret);
+
 		purple_connection_error_reason (js->gc,
 			PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 			_("XML Parse error"));


More information about the Commits mailing list