Re: Missing NULL check after calling ecpg_strdup

Aleksander Alekseev <aleksander@tigerdata.com>

From: Aleksander Alekseev <aleksander@tigerdata.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers@lists.postgresql.org, Evgeniy Gorbanev <gorbanyoves@basealt.ru>
Date: 2025-07-18T13:45:44Z
Lists: pgsql-hackers

Attachments

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.

Commits

  1. ecpg: Improve error detection around ecpg_strdup()

  2. ecpg: Fix NULL pointer dereference during connection lookup