Re: Avoid possible dereference null pointer (contrib/postgres_fdw/postgres_fdw.c)

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid possible dereference null pointer (contrib/postgres_fdw/postgres_fdw.c)
Date: 2025-06-17 05:38:11
Message-ID: 2456c0bf-49a0-4792-9c7e-eee6b8bc339c@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2025-06-17 05:46:28 Re: Mention the default io_method?
Previous Message Peter Eisentraut 2025-06-17 05:27:28 Re: wrong comments in rewriteTargetListIU