Mercurial > pidgin
changeset 23425:0eca6c183d60
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.
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Fri, 04 Jul 2008 16:07:20 +0000 |
parents | 1b3aea146613 |
children | ce361cc8e43b |
files | libpurple/protocols/jabber/parser.c |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/parser.c Fri Jul 04 15:41:26 2008 +0000 +++ b/libpurple/protocols/jabber/parser.c Fri Jul 04 16:07:20 2008 +0000 @@ -199,12 +199,16 @@ 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"));