Re: [PATCH] Add pretty-printed XML output option
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jim Jones <jim.jones@uni-muenster.de>
Cc: Peter Smith <smithpb2250@gmail.com>,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>,
Nikolay Samokhvalov <samokhvalov@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Andrey Borodin <amborodin86@gmail.com>
Date: 2025-05-21T23:48:05Z
Lists: pgsql-hackers
Jim Jones <jim.jones@uni-muenster.de> writes: > On 21.05.25 22:20, Tom Lane wrote: >> It turns out that xmlDocSetRootElement() doesn't >> merely install the given root node: it unlinks the document's old >> root node and returns it to you. If you don't free it, it's leaked >> (for the session, since this is a malloc not palloc). > The xmlsoft examples are a bit misleading though [1] Yeah. I also did some searching on http://codesearch.debian.net and was hard put to it to find anything that pays attention to xmlDocSetRootElement's result at all. I wonder how many of those represent leaks. > It seems that xml_parse has the same issue[3] I did look at that one too. I think it's fine, because we're dealing with a newly-created document which can't have a root node yet. (Reinforcing this, Valgrind sees no leaks after applying my patch.) I considered adding an assertion that that call returns NULL, but concluded that it wasn't worth the notational hassle. I'm not strongly set on that conclusion, though, if you think differently. regards, tom lane
Commits
-
Fix memory leak in XMLSERIALIZE(... INDENT).
- f24605e2dc16 18.0 landed
- ee58de10084b 16.10 landed
- 20bae0690322 17.6 landed
-
doc: Move documentation of md5_password_warnings to a better place
- f3622b64762b 18.0 cited
-
Support [NO] INDENT option in XMLSERIALIZE().
- 483bdb2afec9 16.0 landed
-
Add an expected-file to match behavior of latest libxml2.
- 085423e3e326 9.6.0 cited