Re: Regression with large XML data input - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Regression with large XML data input
Date
Msg-id 1350067.1753817017@sss.pgh.pa.us
Whole thread Raw
In response to Re: Regression with large XML data input  (Jim Jones <jim.jones@uni-muenster.de>)
List pgsql-hackers
Jim Jones <jim.jones@uni-muenster.de> writes:
> I also didn't spot any leaks, but I was rather hesitant to remove it
> after re-reading the code, since there's still a risk of leakage if the
> caller fails to free parsed_nodes in case of an error. However, it seems
> that only xmltotext_with_options relies on this, and even then, the
> result of parsed_nodes is added to a document that gets freed in case of
> failure, so it looks like we're covered.

Yeah, that's a separate issue: once we assign it to *parsed_nodes,
it's on the caller's head to make sure it's freed.  I also spent
awhile staring at xmltotext_with_options.  The early exit for !indent
is safer than it looks: we can only take that path in DOCUMENT mode,
and we won't have any content nodes in that case.  But if we hit
an error somewhere between there and attaching the content nodes to
the document, they'd get leaked.  It looks to me like the only
plausible way for that to happen is an OOM failure within libxml2
operations, which is unlikely but not impossible.  So perhaps it's
worth the trouble to make xmltotext_with_options more wary.

            regards, tom lane



pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Doc update proposal for the note on log_statement in the runtime config for logging page
Next
From: Andrew Dunstan
Date:
Subject: Re: Non-text mode for pg_dumpall