ecpg: Fix NULL pointer dereference during connection lookup

Michael Paquier <michael@paquier.xyz>

Commit: 313d3102facdc61317d1292ab8f2d6cf1f254282
Author: Michael Paquier <michael@paquier.xyz>
Date: 2025-07-22T05:00:07Z
Releases: 16.10
ecpg: Fix NULL pointer dereference during connection lookup

ECPGconnect() caches established connections to the server, supporting
the case of a NULL connection name when a database name is not specified
by its caller.

A follow-up call to ECPGget_PGconn() to get an established connection
from the cached set with a non-NULL name could cause a NULL pointer
dereference if a NULL connection was listed in the cache and checked for
a match.  At least two connections are necessary to reproduce the issue:
one with a NULL name and one with a non-NULL name.

Author:  Aleksander Alekseev <aleksander@tigerdata.com>
Discussion: https://postgr.es/m/CAJ7c6TNvFTPUTZQuNAoqgzaSGz-iM4XR61D7vEj5PsQXwg2RyA@mail.gmail.com
Backpatch-through: 13

Files

PathChange+/−
src/interfaces/ecpg/ecpglib/connect.c modified +6 −1

Discussion