Skip to content

Commit 9bacdf9

Browse files
committed
Don't leak malloc'd error string in libpqrcv_check_conninfo().
We leaked the error report from PQconninfoParse, when there was one. It seems unlikely that real usage patterns would repeat the failure often enough to create serious bloat, but let's back-patch anyway to keep the code similar in all branches. Found via valgrind testing. Back-patch to v10 where this code was added. Discussion: https://postgr.es/m/3816764.1616104288@sss.pgh.pa.us
1 parent 377b7a8 commit 9bacdf9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,15 @@ libpqrcv_check_conninfo(const char *conninfo)
246246

247247
opts = PQconninfoParse(conninfo, &err);
248248
if (opts == NULL)
249+
{
250+
/* The error string is malloc'd, so we must free it explicitly */
251+
char *errcopy = err ? pstrdup(err) : "out of memory";
252+
253+
PQfreemem(err);
249254
ereport(ERROR,
250255
(errcode(ERRCODE_SYNTAX_ERROR),
251-
errmsg("invalid connection string syntax: %s", err)));
256+
errmsg("invalid connection string syntax: %s", errcopy)));
257+
}
252258

253259
PQconninfoFree(opts);
254260
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy