Re: jsonapi: scary new warnings with LTO enabled - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: jsonapi: scary new warnings with LTO enabled
Date
Msg-id 25801148-284F-41F9-A279-A4CF92623C77@yesql.se
Whole thread Raw
In response to Re: jsonapi: scary new warnings with LTO enabled  (Jacob Champion <jacob.champion@enterprisedb.com>)
List 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


Attachment

pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Unicode full case mapping: PG_UNICODE_FAST, and standard-compliant UCS_BASIC
Next
From: Chapman Flack
Date:
Subject: Re: transforms