7
7
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.48 2007/10/13 20:18:41 tgl Exp $
10
+ * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.49 2007/10/13 20:46:47 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -774,13 +774,17 @@ xmlvalidate(PG_FUNCTION_ARGS)
774
774
#if 0
775
775
if (uri )
776
776
xmlFreeURI (uri );
777
+ uri = NULL ;
777
778
#endif
778
779
if (dtd )
779
780
xmlFreeDtd (dtd );
781
+ dtd = NULL ;
780
782
if (doc )
781
783
xmlFreeDoc (doc );
784
+ doc = NULL ;
782
785
if (ctxt )
783
786
xmlFreeParserCtxt (ctxt );
787
+ ctxt = NULL ;
784
788
xmlCleanupParser ();
785
789
}
786
790
PG_CATCH ();
@@ -1163,13 +1167,13 @@ xml_parse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace, xml
1163
1167
1164
1168
if (ctxt )
1165
1169
xmlFreeParserCtxt (ctxt );
1170
+ ctxt = NULL ;
1166
1171
xmlCleanupParser ();
1167
1172
}
1168
1173
PG_CATCH ();
1169
1174
{
1170
1175
if (doc )
1171
1176
xmlFreeDoc (doc );
1172
- doc = NULL ;
1173
1177
if (ctxt )
1174
1178
xmlFreeParserCtxt (ctxt );
1175
1179
xmlCleanupParser ();
@@ -3203,10 +3207,12 @@ xpath(PG_FUNCTION_ARGS)
3203
3207
"invalid XPath expression" ); /* TODO: show proper XPath error details */
3204
3208
3205
3209
xpathobj = xmlXPathCompiledEval (xpathcomp , xpathctx );
3206
- xmlXPathFreeCompExpr (xpathcomp );
3207
3210
if (xpathobj == NULL )
3208
3211
ereport (ERROR , (errmsg ("could not create XPath object" ))); /* TODO: reason? */
3209
3212
3213
+ xmlXPathFreeCompExpr (xpathcomp );
3214
+ xpathcomp = NULL ;
3215
+
3210
3216
/* return empty array in cases when nothing is found */
3211
3217
if (xpathobj -> nodesetval == NULL )
3212
3218
res_nitems = 0 ;
@@ -3225,9 +3231,13 @@ xpath(PG_FUNCTION_ARGS)
3225
3231
}
3226
3232
3227
3233
xmlXPathFreeObject (xpathobj );
3234
+ xpathobj = NULL ;
3228
3235
xmlXPathFreeContext (xpathctx );
3229
- xmlFreeParserCtxt ( ctxt ) ;
3236
+ xpathctx = NULL ;
3230
3237
xmlFreeDoc (doc );
3238
+ doc = NULL ;
3239
+ xmlFreeParserCtxt (ctxt );
3240
+ ctxt = NULL ;
3231
3241
xmlCleanupParser ();
3232
3242
}
3233
3243
PG_CATCH ();
0 commit comments