]> granicus.if.org Git - postgresql/commitdiff
Some time ago John Gray <jgray@azuli.co.uk> and myself worked out and
authorBruce Momjian <bruce@momjian.us>
Fri, 6 Dec 2002 03:44:14 +0000 (03:44 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 6 Dec 2002 03:44:14 +0000 (03:44 +0000)
tested a patch to contrib/xml where the existing code was causing
postgres to crash when it encountered & entities in the XML. I've
enclosed a patch that John came up with to correct this problem. It
patches against 7.3 and will apply on 7.2x if the elog WARNING calls
are changed to elog NOTICE.

Michael Richards

contrib/xml/pgxml_dom.c

index 0c22aced0654060a9e3457921151fe74b85278cb..f79183824eb450f0dba9f717b67923871c7988ab 100644 (file)
@@ -87,10 +87,10 @@ pgxml_parse(PG_FUNCTION_ARGS)
        doctree = xmlParseMemory((char *) VARDATA(t), docsize);
        if (doctree == NULL)
        {
-               /* xmlCleanupParser(); */
+                xmlCleanupParser();
                PG_RETURN_BOOL(false);  /* i.e. not well-formed */
        }
-       /* xmlCleanupParser(); */
+       xmlCleanupParser(); 
        xmlFreeDoc(doctree);
        PG_RETURN_BOOL(true);
 }
@@ -202,7 +202,8 @@ pgxml_xpath(PG_FUNCTION_ARGS)
 
        doctree = xmlParseMemory((char *) VARDATA(t), docsize);
        if (doctree == NULL)
-       {                                                       /* not well-formed */
+       {              /* not well-formed */
+         xmlCleanupParser();
                PG_RETURN_NULL();
        }
 
@@ -216,6 +217,7 @@ pgxml_xpath(PG_FUNCTION_ARGS)
                elog(WARNING, "XPath syntax error");
                xmlFreeDoc(doctree);
                pfree((void *) xpath);
+               xmlCleanupParser();
                PG_RETURN_NULL();
        }
 
@@ -227,6 +229,7 @@ pgxml_xpath(PG_FUNCTION_ARGS)
        {
                xmlFreeDoc(doctree);
                pfree((void *) xpath);
+               xmlCleanupParser();
                PG_RETURN_NULL();               /* seems appropriate */
        }
        /* now we dump this node, ?surrounding by tags? */
@@ -257,6 +260,6 @@ pgxml_xpath(PG_FUNCTION_ARGS)
        xmlFreeDoc(doctree);
        pfree((void *) xpath);
        xmlFree(xpresstr);
-
+       xmlCleanupParser();
        PG_RETURN_TEXT_P(xpres);
 }