Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita102090

Browse files
committed
Remove xmlCleanupParser calls from contrib/xml2.
These are unnecessary and probably dangerous. I don't see any immediaterisk situations in the core XML support or contrib/xml2 itself, but therecould be issues with external uses of libxml2, and in any case it's anaccident waiting to happen.
1 parent7363282 commita102090

File tree

2 files changed

+6
-35
lines changed

2 files changed

+6
-35
lines changed

‎contrib/xml2/xpath.c

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.27 2010/02/28 21:31:57 tgl Exp $
2+
* $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.28 2010/03/01 05:16:35 tgl Exp $
33
*
44
* Parser interface for DOM-based parser (libxml) rather than
55
* stream-based SAX-type parser
@@ -145,12 +145,8 @@ xml_is_well_formed(PG_FUNCTION_ARGS)
145145

146146
doctree=xmlParseMemory((char*)VARDATA(t),docsize);
147147
if (doctree==NULL)
148-
{
149-
xmlCleanupParser();
150148
PG_RETURN_BOOL(false);/* i.e. not well-formed */
151-
}
152149
xmlFreeDoc(doctree);
153-
xmlCleanupParser();
154150
PG_RETURN_BOOL(true);
155151
}
156152

@@ -297,7 +293,6 @@ xpath_nodeset(PG_FUNCTION_ARGS)
297293
xpres=pgxml_result_to_text(pgxml_xpath(PG_GETARG_TEXT_P(0),xpath),
298294
toptag,septag,NULL);
299295

300-
/* xmlCleanupParser(); done by result_to_text routine */
301296
pfree(xpath);
302297

303298
if (xpres==NULL)
@@ -332,7 +327,6 @@ xpath_list(PG_FUNCTION_ARGS)
332327
xpres=pgxml_result_to_text(pgxml_xpath(PG_GETARG_TEXT_P(0),xpath),
333328
NULL,NULL,plainsep);
334329

335-
/* xmlCleanupParser(); done by result_to_text routine */
336330
pfree(xpath);
337331

338332
if (xpres==NULL)
@@ -371,7 +365,6 @@ xpath_string(PG_FUNCTION_ARGS)
371365
xpres=pgxml_result_to_text(pgxml_xpath(PG_GETARG_TEXT_P(0),xpath),
372366
NULL,NULL,NULL);
373367

374-
xmlCleanupParser();
375368
pfree(xpath);
376369

377370
if (xpres==NULL)
@@ -403,13 +396,10 @@ xpath_number(PG_FUNCTION_ARGS)
403396
pfree(xpath);
404397

405398
if (res==NULL)
406-
{
407-
xmlCleanupParser();
408399
PG_RETURN_NULL();
409-
}
410400

411401
fRes=xmlXPathCastToNumber(res);
412-
xmlCleanupParser();
402+
413403
if (xmlXPathIsNaN(fRes))
414404
PG_RETURN_NULL();
415405

@@ -440,13 +430,10 @@ xpath_bool(PG_FUNCTION_ARGS)
440430
pfree(xpath);
441431

442432
if (res==NULL)
443-
{
444-
xmlCleanupParser();
445433
PG_RETURN_BOOL(false);
446-
}
447434

448435
bRes=xmlXPathCastToBoolean(res);
449-
xmlCleanupParser();
436+
450437
PG_RETURN_BOOL(bRes);
451438
}
452439

@@ -469,9 +456,7 @@ pgxml_xpath(text *document, xmlChar *xpath)
469456

470457
doctree=xmlParseMemory((char*)VARDATA(document),docsize);
471458
if (doctree==NULL)
472-
{/* not well-formed */
473-
returnNULL;
474-
}
459+
returnNULL;/* not well-formed */
475460

476461
ctxt=xmlXPathNewContext(doctree);
477462
ctxt->node=xmlDocGetRootElement(doctree);
@@ -480,7 +465,6 @@ pgxml_xpath(text *document, xmlChar *xpath)
480465
comppath=xmlXPathCompile(xpath);
481466
if (comppath==NULL)
482467
{
483-
xmlCleanupParser();
484468
xmlFreeDoc(doctree);
485469
elog_error("XPath Syntax Error", true);
486470
}
@@ -492,7 +476,6 @@ pgxml_xpath(text *document, xmlChar *xpath)
492476
if (res==NULL)
493477
{
494478
xmlXPathFreeContext(ctxt);
495-
/* xmlCleanupParser(); */
496479
xmlFreeDoc(doctree);
497480

498481
returnNULL;
@@ -511,10 +494,8 @@ pgxml_result_to_text(xmlXPathObjectPtr res,
511494
text*xpres;
512495

513496
if (res==NULL)
514-
{
515-
xmlCleanupParser();
516497
returnNULL;
517-
}
498+
518499
switch (res->type)
519500
{
520501
caseXPATH_NODESET:
@@ -536,9 +517,6 @@ pgxml_result_to_text(xmlXPathObjectPtr res,
536517
xpres=cstring_to_text((char*)xpresstr);
537518

538519
/* Free various storage */
539-
xmlCleanupParser();
540-
/* xmlFreeDoc(doctree); -- will die at end of tuple anyway */
541-
542520
xmlFree(xpresstr);
543521

544522
elog_error("XPath error", false);
@@ -779,7 +757,6 @@ xpath_table(PG_FUNCTION_ARGS)
779757
comppath=xmlXPathCompile(xpaths[j]);
780758
if (comppath==NULL)
781759
{
782-
xmlCleanupParser();
783760
xmlFreeDoc(doctree);
784761
elog_error("XPath Syntax Error", true);
785762
}
@@ -844,8 +821,6 @@ xpath_table(PG_FUNCTION_ARGS)
844821
pfree(xmldoc);
845822
}
846823

847-
xmlCleanupParser();
848-
849824
tuplestore_donestoring(tupstore);
850825

851826
SPI_finish();

‎contrib/xml2/xslt_proc.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.17 2010/02/28 19:51:37 tgl Exp $
2+
* $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.18 2010/03/01 05:16:35 tgl Exp $
33
*
44
* XSLT processing functions (requiring libxslt)
55
*
@@ -79,7 +79,6 @@ xslt_process(PG_FUNCTION_ARGS)
7979

8080
if (doctree==NULL)
8181
{
82-
xmlCleanupParser();
8382
elog_error("error parsing XML document", false);
8483

8584
PG_RETURN_NULL();
@@ -93,7 +92,6 @@ xslt_process(PG_FUNCTION_ARGS)
9392
if (ssdoc==NULL)
9493
{
9594
xmlFreeDoc(doctree);
96-
xmlCleanupParser();
9795
elog_error("error parsing stylesheet as XML document", false);
9896
PG_RETURN_NULL();
9997
}
@@ -108,7 +106,6 @@ xslt_process(PG_FUNCTION_ARGS)
108106
{
109107
xmlFreeDoc(doctree);
110108
xsltCleanupGlobals();
111-
xmlCleanupParser();
112109
elog_error("failed to parse stylesheet", false);
113110
PG_RETURN_NULL();
114111
}
@@ -121,7 +118,6 @@ xslt_process(PG_FUNCTION_ARGS)
121118
xmlFreeDoc(doctree);
122119

123120
xsltCleanupGlobals();
124-
xmlCleanupParser();
125121

126122
if (resstat<0)
127123
PG_RETURN_NULL();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp