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

From: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: 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 09:08:50
Message-ID: CAPmGK14X_zpZu+pBvbTuA=WtdJOrFnO-qQU1vdyDz54_Njbs5Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Jun 17, 2025 at 2:38 PM Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2025-06-17 09:31:30 Re: wrong comments in rewriteTargetListIU
Previous Message Peter Eisentraut 2025-06-17 09:01:13 Re: [PATCH] Add an ldflags_sl meson build option