On 22.05.25 01:48, Tom Lane wrote:
> 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.
I see. In that case I believe that at least a different comment
explaining this decision would avoid confusion. Something like
/*
* This attaches root to doc, so we do not need to free it separately.
* The return value of xmlDocSetRootElement (xmlNodePtr) is intentionally
* ignored here, as it is guaranteed to be NULL in this specific context.
* When using this function elsewhere, ensure to handle the return value
* properly.
*/
Best regards, Jim