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 102E1997-FB99-4091-926C-9A8BB3EA168E@yesql.se
Whole thread Raw
In response to Re: jsonapi: scary new warnings with LTO enabled  (Jacob Champion <jacob.champion@enterprisedb.com>)
Responses Re: jsonapi: scary new warnings with LTO enabled
List pgsql-hackers
> On 21 Apr 2025, at 20:28, Jacob Champion <jacob.champion@enterprisedb.com> wrote:
>
> On Mon, Apr 21, 2025 at 11:20 AM Daniel Gustafsson <daniel@yesql.se> wrote:
>> Sure, but I fear we'll get an endless stream of static analysis reports for the
>> allocation leaking if we don't free it.
>
> But we do free it, in freeJsonLexContext(). That usage of the API goes
> back to 2023, with 1c99cde2f344. Or am I misunderstanding?

We do, but with the current coding we call setJsonLexContextOwnsTokens
immediately after creation which derefences the pointer without checkinf for
allocation failure.  This means we dereference the pointer before we can check
for an OOM return from pg_parse_json which even if safe seems to violate code
readability no?

--
Daniel Gustafsson




pgsql-hackers by date:

Previous
From: Jacob Champion
Date:
Subject: Re: jsonapi: scary new warnings with LTO enabled
Next
From: Devrim Gündüz
Date:
Subject: Re: [PoC] Federated Authn/z with OAUTHBEARER