Re: jsonapi: scary new warnings with LTO enabled

Поиск
Список
Период
Сортировка
От Daniel Gustafsson
Тема Re: jsonapi: scary new warnings with LTO enabled
Дата
Msg-id 25801148-284F-41F9-A279-A4CF92623C77@yesql.se
обсуждение исходный текст
Ответ на Re: jsonapi: scary new warnings with LTO enabled  (Jacob Champion <jacob.champion@enterprisedb.com>)
Ответы Re: jsonapi: scary new warnings with LTO enabled
Список pgsql-hackers
> On 17 Apr 2025, at 17:48, Jacob Champion <jacob.champion@enterprisedb.com> wrote:
>
> On Thu, Apr 17, 2025 at 8:20 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I confirm this silences those warnings on my Fedora 41 box.
>
> Instead of doing
>
>    lex = calloc(...);
>    /* (error out on NULL return) */
>    makeJsonLexContextCstringLen(lex, ...);
>
> we need to do
>
>    lex = makeJsonLexContextCstringLen(NULL, ...);
>    /* (error out on NULL return) */
>
> so that JSONLEX_FREE_STRUCT is set correctly. Otherwise we'll leak the
> main allocation:

Since there is no way to determine if the allocation succeeded from outside of
the JSON api it might be better to keep the calloc and explicitly free it?

(Could a JsonLexContextBroken() function be useful perhaps?)

--
Daniel Gustafsson


Вложения

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