adium: 212a16ca: libpurple_jabber_parser_error_handler.di...

evands at pidgin.im evands at pidgin.im
Wed Jan 14 08:37:14 EST 2009


-----------------------------------------------------------------
Revision: 212a16caf2b938700c44727a91cd89f80549bbee
Ancestor: 6565bce0b70f4d48001f991cfa6c014798d5cb3b
Author: evands at pidgin.im
Date: 2009-01-14T13:25:23
Branch: im.pidgin.adium
URL: http://d.pidgin.im/viewmtn/revision/info/212a16caf2b938700c44727a91cd89f80549bbee

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

ChangeLog: 

libpurple_jabber_parser_error_handler.diff:
Fixes the crash on Mac OS X:
Thread 0 Crashed:
0   <<00000000>> 	0xfffeff40 objc_msgSend_rtp + 64
1   com.apple.Foundation           	0x92cb1d78 _structuredErrorFunc + 48
2   libxml2.2.dylib                	0x91d60cd8 __xmlRaiseError + 1220
3   libxml2.2.dylib                	0x91d6341c xmlSubstituteEntitiesDefault + 1588
4   libxml2.2.dylib                	0x91d56c94 xmlParseChunk + 560
5   libpurple                      	0x0b48bc0c jabber_parser_free + 68
}}}
as seen in [http://www.smartcrashreports.com/dev/crash.php?id=18c42ee7244c3effb7527f91b6f55d8aadaf1571 this crash report].

A same-looking crash, with a Foundation-supplied structured error function crashing while attempting to message some unknown ObjC object (or messaging random memory which happens to route through `objc_*`), can be found in [http://www.cocoabuilder.com/archive/message/cocoa/2007/2/27/179496 this cocoadev thread].

Perusing the libxml2 2.6.16 code indicates that supplying our own handler should avoid using the system-supplied one. (How the system is supplying one, I'm not sure, since a call to `xmlSetStructuredErrorFunc()` would be necessary, I think)

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/parser.c	c3df562882edc4bc0389b57d0a1049505e8e1a25
+++ libpurple/protocols/jabber/parser.c	f45f043f74a4a51786e8af789a3bea8674401ac3
@@ -216,6 +216,8 @@ void jabber_parser_free(JabberStream *js
 
 void jabber_parser_free(JabberStream *js) {
 	if (js->context) {
+		xmlSetStructuredErrorFunc(NULL, jabber_parser_structured_error_handler);
+
 		xmlParseChunk(js->context, NULL,0,1);
 		xmlFreeParserCtxt(js->context);
 		js->context = NULL;
@@ -226,6 +228,8 @@ void jabber_parser_process(JabberStream 
 {
 	int ret;
 
+	xmlSetStructuredErrorFunc(NULL, jabber_parser_structured_error_handler);
+
 	if (js->context == NULL) {
 		/* libxml inconsistently starts parsing on creating the
 		 * parser, so do a ParseChunk right afterwards to force it. */


More information about the Commits mailing list