Small memory fixes for pg_createsubcriber

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Small memory fixes for pg_createsubcriber
Date: 2025-02-10 16:31:20
Message-ID: CAEudQAp=AW5dJXrGLbC_aZg_9nOo=42W7uLDRONFQE-gcgnkgQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

Per Coverity.

Coverity has some reports about pg_createsubcriber.

CID 1591322: (#1 of 1): Resource leak (RESOURCE_LEAK)
10. leaked_storage: Variable dbname going out of scope leaks the storage it
points to.

Additionally there are several calls that are out of the ordinary,
according to the Postgres API.

According to the documentation:
libpq-exec <https://www.postgresql.org/docs/current/libpq-exec.html>

The correct function to free memory when using PQescapeLiteral and
PQescapeIdentifier would be PQfreemem.

Trivial fixes attached.

best regards,
Ranier Vilela

Attachment Content-Type Size
fix-resource-leak-and-api-misuse-pg_createsubcriber.patch application/octet-stream 2.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ilia Evdokimov 2025-02-10 16:38:50 Re: explain analyze rows=%.0f
Previous Message Jacob Champion 2025-02-10 16:23:30 Re: [PATCH] pg_stat_activity: make slow/hanging authentication more visible