1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Back-patch today's memory management fixups in contrib/xml2.

Prior to 8.3, these changes are not critical for compatibility with core
Postgres, since core had no libxml2 calls then.  However there is still
a risk if contrib/xml2 is used along with libxml2 functionality in Perl
or other loadable modules.  So back-patch to all versions.

Also back-patch addition of regression tests.  I'm not sure how many of
the cases are interesting without the interaction with core xml code,
but a silly regression test is still better than none at all.
This commit is contained in:
Tom Lane
2010-03-01 03:41:04 +00:00
parent a7ac5c64fd
commit 8748dc3580
5 changed files with 388 additions and 228 deletions

View File

@ -1,5 +1,5 @@
/*
* $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.15.2.1 2009/07/10 00:32:06 tgl Exp $
* $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.15.2.2 2010/03/01 03:41:04 tgl Exp $
*
* XSLT processing functions (requiring libxslt)
*
@ -27,16 +27,16 @@
#include <libxslt/xsltutils.h>
/* declarations to come from xpath.c */
extern void elog_error(int level, char *explain, int force);
extern void pgxml_parser_init();
extern xmlChar *pgxml_texttoxmlchar(text *textstring);
/* local defs */
static void parse_params(const char **params, text *paramstr);
/* externally accessible functions */
Datum xslt_process(PG_FUNCTION_ARGS);
/* declarations to come from xpath.c */
extern void elog_error(const char *explain, bool force);
extern void pgxml_parser_init(void);
/* local defs */
static void parse_params(const char **params, text *paramstr);
#define MAXPARAMS 20 /* must be even, see parse_params() */
@ -80,7 +80,7 @@ xslt_process(PG_FUNCTION_ARGS)
if (doctree == NULL)
{
xmlCleanupParser();
elog_error(ERROR, "error parsing XML document", 0);
elog_error("error parsing XML document", false);
PG_RETURN_NULL();
}
@ -94,7 +94,7 @@ xslt_process(PG_FUNCTION_ARGS)
{
xmlFreeDoc(doctree);
xmlCleanupParser();
elog_error(ERROR, "error parsing stylesheet as XML document", 0);
elog_error("error parsing stylesheet as XML document", false);
PG_RETURN_NULL();
}
@ -109,7 +109,7 @@ xslt_process(PG_FUNCTION_ARGS)
xmlFreeDoc(doctree);
xsltCleanupGlobals();
xmlCleanupParser();
elog_error(ERROR, "failed to parse stylesheet", 0);
elog_error("failed to parse stylesheet", false);
PG_RETURN_NULL();
}