]> granicus.if.org Git - postgresql/commit
Free libxml2/libxslt resources in a safer order.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 27 Nov 2014 16:12:51 +0000 (11:12 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 27 Nov 2014 16:12:51 +0000 (11:12 -0500)
commitc393847a1f8b35252f880853a2fd5eabd9a6d7b0
tree43382e03304010c87d764b2d0a879a7e5e6553eb
parent08cd4d9a64b2313b87625a0abbca05096345deab
Free libxml2/libxslt resources in a safer order.

Mark Simonetti reported that libxslt sometimes crashes for him, and that
swapping xslt_process's object-freeing calls around to do them in reverse
order of creation seemed to fix it.  I've not reproduced the crash, but
valgrind clearly shows a reference to already-freed memory, which is
consistent with the idea that shutdown of the xsltTransformContext is
trying to reference the already-freed stylesheet or input document.
With this patch, valgrind is no longer unhappy.

I have an inquiry in to see if this is a libxslt bug or if we're just
abusing the library; but even if it's a library bug, we'd want to adjust
our code so it doesn't fail with unpatched libraries.

Back-patch to all supported branches, because we've been doing this in
the wrong(?) order for a long time.
contrib/xml2/xslt_proc.c