Remove xmlCleanupParser calls from contrib/xml2.
These are unnecessary and probably dangerous. I don't see any immediate risk situations in the core XML support or contrib/xml2 itself, but there could be issues with external uses of libxml2, and in any case it's an accident waiting to happen.
This commit is contained in:
parent
8748dc3580
commit
5ea32f560a
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.23.2.2 2010/03/01 03:41:04 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.23.2.3 2010/03/01 05:16:40 tgl Exp $
|
||||||
*
|
*
|
||||||
* Parser interface for DOM-based parser (libxml) rather than
|
* Parser interface for DOM-based parser (libxml) rather than
|
||||||
* stream-based SAX-type parser
|
* stream-based SAX-type parser
|
||||||
@ -145,12 +145,8 @@ xml_is_well_formed(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
doctree = xmlParseMemory((char *) VARDATA(t), docsize);
|
doctree = xmlParseMemory((char *) VARDATA(t), docsize);
|
||||||
if (doctree == NULL)
|
if (doctree == NULL)
|
||||||
{
|
|
||||||
xmlCleanupParser();
|
|
||||||
PG_RETURN_BOOL(false); /* i.e. not well-formed */
|
PG_RETURN_BOOL(false); /* i.e. not well-formed */
|
||||||
}
|
|
||||||
xmlFreeDoc(doctree);
|
xmlFreeDoc(doctree);
|
||||||
xmlCleanupParser();
|
|
||||||
PG_RETURN_BOOL(true);
|
PG_RETURN_BOOL(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +293,6 @@ xpath_nodeset(PG_FUNCTION_ARGS)
|
|||||||
xpres = pgxml_result_to_text(pgxml_xpath(PG_GETARG_TEXT_P(0), xpath),
|
xpres = pgxml_result_to_text(pgxml_xpath(PG_GETARG_TEXT_P(0), xpath),
|
||||||
toptag, septag, NULL);
|
toptag, septag, NULL);
|
||||||
|
|
||||||
/* xmlCleanupParser(); done by result_to_text routine */
|
|
||||||
pfree(xpath);
|
pfree(xpath);
|
||||||
|
|
||||||
if (xpres == NULL)
|
if (xpres == NULL)
|
||||||
@ -332,7 +327,6 @@ xpath_list(PG_FUNCTION_ARGS)
|
|||||||
xpres = pgxml_result_to_text(pgxml_xpath(PG_GETARG_TEXT_P(0), xpath),
|
xpres = pgxml_result_to_text(pgxml_xpath(PG_GETARG_TEXT_P(0), xpath),
|
||||||
NULL, NULL, plainsep);
|
NULL, NULL, plainsep);
|
||||||
|
|
||||||
/* xmlCleanupParser(); done by result_to_text routine */
|
|
||||||
pfree(xpath);
|
pfree(xpath);
|
||||||
|
|
||||||
if (xpres == NULL)
|
if (xpres == NULL)
|
||||||
@ -371,7 +365,6 @@ xpath_string(PG_FUNCTION_ARGS)
|
|||||||
xpres = pgxml_result_to_text(pgxml_xpath(PG_GETARG_TEXT_P(0), xpath),
|
xpres = pgxml_result_to_text(pgxml_xpath(PG_GETARG_TEXT_P(0), xpath),
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
xmlCleanupParser();
|
|
||||||
pfree(xpath);
|
pfree(xpath);
|
||||||
|
|
||||||
if (xpres == NULL)
|
if (xpres == NULL)
|
||||||
@ -403,13 +396,10 @@ xpath_number(PG_FUNCTION_ARGS)
|
|||||||
pfree(xpath);
|
pfree(xpath);
|
||||||
|
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
{
|
|
||||||
xmlCleanupParser();
|
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
}
|
|
||||||
|
|
||||||
fRes = xmlXPathCastToNumber(res);
|
fRes = xmlXPathCastToNumber(res);
|
||||||
xmlCleanupParser();
|
|
||||||
if (xmlXPathIsNaN(fRes))
|
if (xmlXPathIsNaN(fRes))
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
@ -440,13 +430,10 @@ xpath_bool(PG_FUNCTION_ARGS)
|
|||||||
pfree(xpath);
|
pfree(xpath);
|
||||||
|
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
{
|
|
||||||
xmlCleanupParser();
|
|
||||||
PG_RETURN_BOOL(false);
|
PG_RETURN_BOOL(false);
|
||||||
}
|
|
||||||
|
|
||||||
bRes = xmlXPathCastToBoolean(res);
|
bRes = xmlXPathCastToBoolean(res);
|
||||||
xmlCleanupParser();
|
|
||||||
PG_RETURN_BOOL(bRes);
|
PG_RETURN_BOOL(bRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,9 +456,7 @@ pgxml_xpath(text *document, xmlChar *xpath)
|
|||||||
|
|
||||||
doctree = xmlParseMemory((char *) VARDATA(document), docsize);
|
doctree = xmlParseMemory((char *) VARDATA(document), docsize);
|
||||||
if (doctree == NULL)
|
if (doctree == NULL)
|
||||||
{ /* not well-formed */
|
return NULL; /* not well-formed */
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctxt = xmlXPathNewContext(doctree);
|
ctxt = xmlXPathNewContext(doctree);
|
||||||
ctxt->node = xmlDocGetRootElement(doctree);
|
ctxt->node = xmlDocGetRootElement(doctree);
|
||||||
@ -480,7 +465,6 @@ pgxml_xpath(text *document, xmlChar *xpath)
|
|||||||
comppath = xmlXPathCompile(xpath);
|
comppath = xmlXPathCompile(xpath);
|
||||||
if (comppath == NULL)
|
if (comppath == NULL)
|
||||||
{
|
{
|
||||||
xmlCleanupParser();
|
|
||||||
xmlFreeDoc(doctree);
|
xmlFreeDoc(doctree);
|
||||||
elog_error("XPath Syntax Error", true);
|
elog_error("XPath Syntax Error", true);
|
||||||
}
|
}
|
||||||
@ -492,7 +476,6 @@ pgxml_xpath(text *document, xmlChar *xpath)
|
|||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
{
|
{
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
/* xmlCleanupParser(); */
|
|
||||||
xmlFreeDoc(doctree);
|
xmlFreeDoc(doctree);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -511,10 +494,8 @@ pgxml_result_to_text(xmlXPathObjectPtr res,
|
|||||||
text *xpres;
|
text *xpres;
|
||||||
|
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
{
|
|
||||||
xmlCleanupParser();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
switch (res->type)
|
switch (res->type)
|
||||||
{
|
{
|
||||||
case XPATH_NODESET:
|
case XPATH_NODESET:
|
||||||
@ -536,9 +517,6 @@ pgxml_result_to_text(xmlXPathObjectPtr res,
|
|||||||
xpres = cstring_to_text((char *) xpresstr);
|
xpres = cstring_to_text((char *) xpresstr);
|
||||||
|
|
||||||
/* Free various storage */
|
/* Free various storage */
|
||||||
xmlCleanupParser();
|
|
||||||
/* xmlFreeDoc(doctree); -- will die at end of tuple anyway */
|
|
||||||
|
|
||||||
xmlFree(xpresstr);
|
xmlFree(xpresstr);
|
||||||
|
|
||||||
elog_error("XPath error", false);
|
elog_error("XPath error", false);
|
||||||
@ -779,7 +757,6 @@ xpath_table(PG_FUNCTION_ARGS)
|
|||||||
comppath = xmlXPathCompile(xpaths[j]);
|
comppath = xmlXPathCompile(xpaths[j]);
|
||||||
if (comppath == NULL)
|
if (comppath == NULL)
|
||||||
{
|
{
|
||||||
xmlCleanupParser();
|
|
||||||
xmlFreeDoc(doctree);
|
xmlFreeDoc(doctree);
|
||||||
elog_error("XPath Syntax Error", true);
|
elog_error("XPath Syntax Error", true);
|
||||||
}
|
}
|
||||||
@ -844,8 +821,6 @@ xpath_table(PG_FUNCTION_ARGS)
|
|||||||
pfree(xmldoc);
|
pfree(xmldoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlCleanupParser();
|
|
||||||
|
|
||||||
tuplestore_donestoring(tupstore);
|
tuplestore_donestoring(tupstore);
|
||||||
|
|
||||||
SPI_finish();
|
SPI_finish();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.15.2.2 2010/03/01 03:41:04 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.15.2.3 2010/03/01 05:16:40 tgl Exp $
|
||||||
*
|
*
|
||||||
* XSLT processing functions (requiring libxslt)
|
* XSLT processing functions (requiring libxslt)
|
||||||
*
|
*
|
||||||
@ -79,7 +79,6 @@ xslt_process(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (doctree == NULL)
|
if (doctree == NULL)
|
||||||
{
|
{
|
||||||
xmlCleanupParser();
|
|
||||||
elog_error("error parsing XML document", false);
|
elog_error("error parsing XML document", false);
|
||||||
|
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
@ -93,7 +92,6 @@ xslt_process(PG_FUNCTION_ARGS)
|
|||||||
if (ssdoc == NULL)
|
if (ssdoc == NULL)
|
||||||
{
|
{
|
||||||
xmlFreeDoc(doctree);
|
xmlFreeDoc(doctree);
|
||||||
xmlCleanupParser();
|
|
||||||
elog_error("error parsing stylesheet as XML document", false);
|
elog_error("error parsing stylesheet as XML document", false);
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
}
|
}
|
||||||
@ -108,7 +106,6 @@ xslt_process(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
xmlFreeDoc(doctree);
|
xmlFreeDoc(doctree);
|
||||||
xsltCleanupGlobals();
|
xsltCleanupGlobals();
|
||||||
xmlCleanupParser();
|
|
||||||
elog_error("failed to parse stylesheet", false);
|
elog_error("failed to parse stylesheet", false);
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
}
|
}
|
||||||
@ -121,7 +118,6 @@ xslt_process(PG_FUNCTION_ARGS)
|
|||||||
xmlFreeDoc(doctree);
|
xmlFreeDoc(doctree);
|
||||||
|
|
||||||
xsltCleanupGlobals();
|
xsltCleanupGlobals();
|
||||||
xmlCleanupParser();
|
|
||||||
|
|
||||||
if (resstat < 0)
|
if (resstat < 0)
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user