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

From Etsuro Fujita
Subject Re: Avoid possible dereference null pointer (contrib/postgres_fdw/postgres_fdw.c)
Date
Msg-id CAPmGK14X_zpZu+pBvbTuA=WtdJOrFnO-qQU1vdyDz54_Njbs5Q@mail.gmail.com
Whole thread Raw
In response to Re: Avoid possible dereference null pointer (contrib/postgres_fdw/postgres_fdw.c)  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Responses Re: Avoid possible dereference null pointer (contrib/postgres_fdw/postgres_fdw.c)
List pgsql-hackers
Hi,

On Tue, Jun 17, 2025 at 2:38 PM Fujii Masao <masao.fujii@oss.nttdata.com> wrote:
>                                 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.

We get here only when called from add_foreign_ordered_paths() or
add_foreign_final_paths(), in which cases fpextra is always set, so it
cannot be NULL.  No?

Best regards,
Etsuro Fujita



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [PATCH] Add an ldflags_sl meson build option
Next
From: Dean Rasheed
Date:
Subject: Re: wrong comments in rewriteTargetListIU