Re: Avoid possible dereference null pointer (contrib/postgres_fdw/postgres_fdw.c) - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Avoid possible dereference null pointer (contrib/postgres_fdw/postgres_fdw.c)
Date
Msg-id 2456c0bf-49a0-4792-9c7e-eee6b8bc339c@oss.nttdata.com
Whole thread Raw
List pgsql-hackers

On 2025/06/17 4:48, Ranier Vilela wrote:
> Hi.
> 
> In the function *estimate_path_cost_size* the parameter
> fpextra can be NULL.

Yes.


> It is necessary to always check its validity,
> as is already done in other parts of the source.
> 
> patch attached.

                  adjust_foreign_grouping_path_cost(root, pathkeys,
                                                    retrieved_rows, width,
-                                                  fpextra->limit_tuples,
+                                                  fpextra ? fpextra->limit_tuples : 0.0,
                                                    &disabled_nodes,
                                                    &startup_cost, &run_cost);

I couldn't find a query that would reach this code path with
fpextra == NULL, but I agree the current code is fragile.
So I think it's a good idea to add the check before accessing
the field.

Regards,

-- 
Fujii Masao
NTT DATA Japan Corporation




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Huge commitfest app update upcoming: Tags, Draft CF, Help page, and automated commitfest creat/open/close
Next
From: John Naylor
Date:
Subject: Re: Vacuum ERRORs out considering freezing dead tuples from before OldestXmin