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

Commita1cd04c

Browse files
committed
Free libxml2/libxslt resources in a safer order.
Mark Simonetti reported that libxslt sometimes crashes for him, and thatswapping xslt_process's object-freeing calls around to do them in reverseorder of creation seemed to fix it. I've not reproduced the crash, butvalgrind clearly shows a reference to already-freed memory, which isconsistent with the idea that shutdown of the xsltTransformContext istrying 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 justabusing the library; but even if it's a library bug, we'd want to adjustour code so it doesn't fail with unpatched libraries.Back-patch to all supported branches, because we've been doing this inthe wrong(?) order for a long time.
1 parent9b468bc commita1cd04c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎contrib/xml2/xslt_proc.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,16 @@ xslt_process(PG_FUNCTION_ARGS)
150150
}
151151
PG_CATCH();
152152
{
153-
if (stylesheet!=NULL)
154-
xsltFreeStylesheet(stylesheet);
155153
if (restree!=NULL)
156154
xmlFreeDoc(restree);
157-
if (doctree!=NULL)
158-
xmlFreeDoc(doctree);
159-
if (xslt_sec_prefs!=NULL)
160-
xsltFreeSecurityPrefs(xslt_sec_prefs);
161155
if (xslt_ctxt!=NULL)
162156
xsltFreeTransformContext(xslt_ctxt);
157+
if (xslt_sec_prefs!=NULL)
158+
xsltFreeSecurityPrefs(xslt_sec_prefs);
159+
if (stylesheet!=NULL)
160+
xsltFreeStylesheet(stylesheet);
161+
if (doctree!=NULL)
162+
xmlFreeDoc(doctree);
163163
xsltCleanupGlobals();
164164

165165
pg_xml_done(xmlerrcxt, true);
@@ -168,11 +168,11 @@ xslt_process(PG_FUNCTION_ARGS)
168168
}
169169
PG_END_TRY();
170170

171-
xsltFreeStylesheet(stylesheet);
172171
xmlFreeDoc(restree);
173-
xmlFreeDoc(doctree);
174-
xsltFreeSecurityPrefs(xslt_sec_prefs);
175172
xsltFreeTransformContext(xslt_ctxt);
173+
xsltFreeSecurityPrefs(xslt_sec_prefs);
174+
xsltFreeStylesheet(stylesheet);
175+
xmlFreeDoc(doctree);
176176
xsltCleanupGlobals();
177177

178178
pg_xml_done(xmlerrcxt, false);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp