adium: 8e1d9c0a: libpurple_xmlnode_parser_error_handler.d...

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


-----------------------------------------------------------------
Revision: 8e1d9c0aaa4508bb252a61a612290cc8e17a8586
Ancestor: 52d0445289e648c528c58c4efa47be163c3a7e1b
Author: evands at pidgin.im
Date: 2009-01-14T13:29:37
Branch: im.pidgin.adium
URL: http://d.pidgin.im/viewmtn/revision/info/8e1d9c0aaa4508bb252a61a612290cc8e17a8586

Modified files:
        libpurple/xmlnode.c

ChangeLog: 

libpurple_xmlnode_parser_error_handler.diff: 
Reset the libxml error handler before the xml parser makes use of it, preventing
the crash which results from Foundation setting its own error handler which
references a released NSXMLParser

-------------- next part --------------
============================================================
--- libpurple/xmlnode.c	8450c70dd642176ba737edf52c09242716190d47
+++ libpurple/xmlnode.c	3ae177616b3b67ae67a7b134611dc4e572afe3fa
@@ -700,6 +700,15 @@ static xmlSAXHandler xmlnode_parser_libx
 	NULL, /* serror */
 };
 
+static void
+libpurple_parser_structured_error_handler(void *user_data, xmlErrorPtr error)
+{
+	purple_debug_error("xmlnode", "XML parser error: "
+					   "Domain %i, code %i, level %i: %s\n",
+					   error->domain, error->code, error->level,
+					   (error->message ? error->message : "(null)"));
+}
+
 xmlnode *
 xmlnode_from_str(const char *str, gssize size)
 {
@@ -712,6 +721,8 @@ xmlnode_from_str(const char *str, gssize
 	real_size = size < 0 ? strlen(str) : size;
 	xpd = g_new0(struct _xmlnode_parser_data, 1);
 
+	xmlSetStructuredErrorFunc(NULL, libpurple_parser_structured_error_handler);
+
 	if (xmlSAXUserParseMemory(&xmlnode_parser_libxml, xpd, str, real_size) < 0) {
 		while(xpd->current && xpd->current->parent)
 			xpd->current = xpd->current->parent;


More information about the Commits mailing list