Re: DEREF_AFTER_NULL: src/common/jsonapi.c:2529 - Mailing list pgsql-hackers

From Jacob Champion
Subject Re: DEREF_AFTER_NULL: src/common/jsonapi.c:2529
Date
Msg-id CAOYmi+m+g1dn8aSuBuKsNK+HCGm9HeD-U747rpSuDQ08vWJM6g@mail.gmail.com
Whole thread Raw
In response to Re: DEREF_AFTER_NULL: src/common/jsonapi.c:2529  (Peter Eisentraut <peter@eisentraut.org>)
List pgsql-hackers
On Wed, Apr 8, 2026 at 2:25 PM Peter Eisentraut <peter@eisentraut.org> wrote:
> This was recently (as in: I still remember it) discussed:
>
> https://www.postgresql.org/message-id/flat/cf26e970-8e92-59f1-247a-aa265235075b%40enterprisedb.com
>
> Probably not worth opening up again.

Fair enough.

> But it seems to me that the pfree() in fe_memutils.c should
> Assert(pointer != NULL), to be consistent with the backend version.

From a quick meson run, it looks like my FREE() macro would be the
only thing that trips that assertion. So yeah, I guess so.

> I've also been thinking sometimes about a pfree_if_nonnull() (which
> would do { if (ptr) pfree(ptr)) }.  That would in some cases make the
> notation more compact and robust.  Maybe it could help here too?

No strong opinion there.

--Jacob



pgsql-hackers by date:

Previous
From: Daniil Davydov
Date:
Subject: Re: Fix bug with accessing to temporary tables of other sessions
Next
From: Sandro Santilli
Date:
Subject: Re: Eliminating SPI / SQL from some RI triggers - take 3