File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -808,12 +808,10 @@ xpath_table(PG_FUNCTION_ARGS)
808
808
xmlXPathCompExprPtr comppath ;
809
809
810
810
/* Extract the row data as C Strings */
811
-
812
811
spi_tuple = tuptable -> vals [i ];
813
812
pkey = SPI_getvalue (spi_tuple , spi_tupdesc , 1 );
814
813
xmldoc = SPI_getvalue (spi_tuple , spi_tupdesc , 2 );
815
814
816
-
817
815
/*
818
816
* Clear the values array, so that not-well-formed documents return
819
817
* NULL in all columns.
@@ -827,11 +825,14 @@ xpath_table(PG_FUNCTION_ARGS)
827
825
values [0 ] = pkey ;
828
826
829
827
/* Parse the document */
830
- doctree = xmlParseMemory (xmldoc , strlen (xmldoc ));
828
+ if (xmldoc )
829
+ doctree = xmlParseMemory (xmldoc , strlen (xmldoc ));
830
+ else /* treat NULL as not well-formed */
831
+ doctree = NULL ;
831
832
832
833
if (doctree == NULL )
833
- { /* not well-formed, so output all-NULL tuple */
834
-
834
+ {
835
+ /* not well-formed, so output all-NULL tuple */
835
836
ret_tuple = BuildTupleFromCStrings (attinmeta , values );
836
837
oldcontext = MemoryContextSwitchTo (per_query_ctx );
837
838
tuplestore_puttuple (tupstore , ret_tuple );
@@ -923,8 +924,10 @@ xpath_table(PG_FUNCTION_ARGS)
923
924
924
925
xmlFreeDoc (doctree );
925
926
926
- pfree (pkey );
927
- pfree (xmldoc );
927
+ if (pkey )
928
+ pfree (pkey );
929
+ if (xmldoc )
930
+ pfree (xmldoc );
928
931
}
929
932
930
933
xmlCleanupParser ();
You can’t perform that action at this time.
0 commit comments