Re: DEREF_AFTER_NULL: src/common/jsonapi.c:2529

From: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Andreas Karlsson <andreas(at)proxel(dot)se>, Галкин Сергей <galkin(at)rutoken(dot)ru>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: DEREF_AFTER_NULL: src/common/jsonapi.c:2529
Date: 2026-04-09 15:59:35
Message-ID: CAOYmi+m+g1dn8aSuBuKsNK+HCGm9HeD-U747rpSuDQ08vWJM6g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 8, 2026 at 2:25 PM Peter Eisentraut <peter(at)eisentraut(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sandro Santilli 2026-04-09 16:01:58 Re: Eliminating SPI / SQL from some RI triggers - take 3
Previous Message Daniil Davydov 2026-04-09 15:29:52 Re: Fix bug with accessing to temporary tables of other sessions