Re: Missing NULL check after calling ecpg_strdup

From: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Evgeniy Gorbanev <gorbanyoves(at)basealt(dot)ru>
Subject: Re: Missing NULL check after calling ecpg_strdup
Date: 2025-07-18 13:45:44
Message-ID: CAJ7c6TNeG-e0BJtgAWT4eU0-tuQ7XZXcPzUe-GsiLuaiXK5tcw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Michael,

Thanks for all your great feedback.

> Or you could keep the "lineno" and the error generated in memory.c as
> this gives enough details about the location where the problem
> happens. We are going to need the extra "alloc_failed".
>
> [...]
>
> Hmm. But both are related and the same problem, no? This is touching
> the same code paths..
>
> [...]
>
> Nope, we could keep this shortcut in ecpg_strdup() as long as there is
> an extra field to track if an error has happened.

OK, patch 0002 implements this idea with minimal changes to the existing logic.

Attachment Content-Type Size
v5-0001-Add-proper-checks-for-ecpg_strdup-return-value.patch text/x-patch 6.3 KB
v5-0002-Add-alloc_failed-argument-to-ecpg_strdup.patch text/x-patch 14.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2025-07-18 13:53:02 Re: IPC/MultixactCreation on the Standby server
Previous Message Bertrand Drouvot 2025-07-18 13:40:55 Re: Fix lwlock.c and wait_event_names.txt discrepancy