From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | wliang(at)stu(dot)xidian(dot)edu(dot)cn, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Report some potential memory leak bugs in pg_dump.c |
Date: | 2022-02-19 07:04:14 |
Message-ID: | 12081.1645254254@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Fri, Feb 18, 2022 at 10:59 PM <wliang(at)stu(dot)xidian(dot)edu(dot)cn> wrote:
>> Specifically, at line 10545 and line 10546, function
>> getFormattedTypeName() is called, which allocates a chunk of memory by
>> using pg_strdup() and returns it.
> I'm not a C programmer but am operating under the assumption that you are
> probably incorrect. So I took a cursory look at the code (in HEAD),
> starting with the function comment. It says:
> "* Note that the result is cached and must not be freed by the caller."
There's also this in the body of the function:
/*
* Cache the result for re-use in later requests, if possible. If we
* don't have a TypeInfo for the type, the string will be leaked once the
* caller is done with it ... but that case really should not happen, so
* leaking if it does seems acceptable.
*/
Since getTypes() makes a TypeInfo for every row of pg_type, "really
should not happen" is an accurate statement. You'd pretty much have to
be dealing with a catalog-corruption scenario for the non-cached path
to be taken.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | wliang | 2022-02-19 08:04:38 | Re all: Report some potential memory leak bugs in pg_dump.c |
Previous Message | David G. Johnston | 2022-02-19 06:15:55 | Re: Report some potential memory leak bugs in pg_dump.c |