Re: Avoid possible deference NULL pointer (src/backend/optimizer/path/allpaths.c)

From: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid possible deference NULL pointer (src/backend/optimizer/path/allpaths.c)
Date: 2025-02-05 16:51:32
Message-ID: 5417d775-121e-4735-99a2-cd0517c67b17@tantorlabs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 05.01.2025 02:29, Ranier Vilela wrote:
> Hi.
>
> Per Coverity.
>
> All call sites of function *get_cheapest_path_for_pathkeys* checks
> for NULL returns.
>
> So, it is highly likely that the function will return NULL.
>
> IMO, the Assert in this particular call, is not fully effective.
>
> Fix removing the Assert and always check if the return is NULL.
>
> best regards,
> Ranier Vilela

Hi!

Thanks for noticing this. If this happens in the planner, it poses a
serious risk of a segmentation fault that could crash the instance if a
NULL pointer is dereferenced. Since checking for NULL is very cheap, I
support this patch.

--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2025-02-05 16:55:06 Re: Avoid possible deference NULL pointer (src/backend/optimizer/path/allpaths.c)
Previous Message Robert Haas 2025-02-05 16:47:22 Re: Eagerly scan all-visible pages to amortize aggressive vacuum