Re: Avoid possible deference NULL pointer (src/backend/optimizer/path/allpaths.c) - Mailing list pgsql-hackers

From Ilia Evdokimov
Subject Re: Avoid possible deference NULL pointer (src/backend/optimizer/path/allpaths.c)
Date
Msg-id 5417d775-121e-4735-99a2-cd0517c67b17@tantorlabs.com
Whole thread Raw
Responses Re: Avoid possible deference NULL pointer (src/backend/optimizer/path/allpaths.c)
List 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.




pgsql-hackers by date:

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