Re: Missing NULL check after calling ecpg_strdup

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Aleksander Alekseev <aleksander@tigerdata.com>
Cc: pgsql-hackers@lists.postgresql.org, Evgeniy Gorbanev <gorbanyoves@basealt.ru>
Date: 2025-07-22T23:34:14Z
Lists: pgsql-hackers
On Tue, Jul 22, 2025 at 04:20:53PM +0300, Aleksander Alekseev wrote:
> v7 may have a compilation warning on Linux:
> 
> ```
> warning: unused variable ‘alloc_failed’ [-Wunused-variable]
> ```
> 
> ... because the only use of the variable is hidden under #ifdef's.

Yep, thanks, didn't see this one coming.  Doing a CI run was still on
my list of things still to do.  I have just done one after a second
lookup and I think that we should be OK.

What you are suggesting for ECPGget_desc() is fine by me at the end.
Both are immediate failure checks and the first one is never expected
to be NULL, but the second with setlocale() needs that, so...

Applied v8 on HEAD.
--
Michael

Commits

  1. ecpg: Improve error detection around ecpg_strdup()

  2. ecpg: Fix NULL pointer dereference during connection lookup