Re: Report some potential memory leak bugs in pg_dump.c

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Report some potential memory leak bugs in pg_dump.c
Дата
Msg-id 12081.1645254254@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Report some potential memory leak bugs in pg_dump.c  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Fri, Feb 18, 2022 at 10:59 PM <wliang@stu.xidian.edu.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



В списке pgsql-bugs по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Report some potential memory leak bugs in pg_dump.c
Следующее
От: wliang@stu.xidian.edu.cn
Дата:
Сообщение: Re all: Report some potential memory leak bugs in pg_dump.c