Avoid resource leak (contrib/postgres_fdw/connection.c)

Ranier Vilela <ranier.vf@gmail.com>

From: Ranier Vilela <ranier.vf@gmail.com>
To: Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-16T11:45:49Z
Lists: pgsql-hackers

Attachments

Hi.

Per Coverity.

CID 1645716: (#1 of 1): Resource leak (RESOURCE_LEAK)
8. leaked_storage: Variable str going out of scope leaks the storage
str.data points to.

The function *postgres_fdw_connection* leaks the contents of
var str.data
Once that function *cstring_to_text* palloc the contents
must be necessary to free the var str.data.

patch attached.

best regards,
Ranier Vilelas