From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
---|---|
To: | Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: jsonapi: scary new warnings with LTO enabled |
Date: | 2025-04-19 21:15:24 |
Message-ID: | 25801148-284F-41F9-A279-A4CF92623C77@yesql.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On 17 Apr 2025, at 17:48, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com> wrote:
>
> On Thu, Apr 17, 2025 at 8:20 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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 | Content-Type | Size |
---|---|---|
v2-0001-Allocate-JsonLexContexts-on-the-heap-to-avoid-war.patch | application/octet-stream | 5.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Chapman Flack | 2025-04-19 21:35:44 | Re: transforms |
Previous Message | Jeff Davis | 2025-04-19 19:30:57 | Re: Unicode full case mapping: PG_UNICODE_FAST, and standard-compliant UCS_BASIC |