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+muy=Wtk0dv6J5HmcFTMvrPMe2MGN2X+hjZL7DKSUEXLQ@mail.gmail.com
Whole thread Raw
In response to Re: DEREF_AFTER_NULL: src/common/jsonapi.c:2529  (Andreas Karlsson <andreas@proxel.se>)
Responses Re: DEREF_AFTER_NULL: src/common/jsonapi.c:2529
List pgsql-hackers
On Mon, Apr 6, 2026 at 4:59 AM Andreas Karlsson <andreas@proxel.se> wrote:
> The code is correct but a bit confusing.

Yeah, it's not great. The need for this (security-critical!) code to
wrangle three separate allocation conventions is error-prone, to say
the least.

> If someone has a patch improving readability

Suggestions?

> adding this noop NULL check to silence a false positive from a
> static analyzer does not seem like an improvement.

We do occasionally merge code to silence false positives, and we could
maybe do something with pg_assume() here, but I agree that it'd be
better to refactor it so that it's obviously correct.

--Jacob



pgsql-hackers by date:

Previous
From: Mihail Nikalayeu
Date:
Subject: Re: Resetting snapshots during the first phase of [CREATE |RE]INDEX CONCURRENTLY
Next
From: Haibo Yan
Date:
Subject: Re: Extract numeric filed in JSONB more effectively