Skip to content

Commit 4eca51d

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 fc552f8 commit 4eca51d

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
@@ -244,9 +244,15 @@ libpqrcv_check_conninfo(const char *conninfo)
244244

245245
opts = PQconninfoParse(conninfo, &err);
246246
if (opts == NULL)
247+
{
248+
/* The error string is malloc'd, so we must free it explicitly */
249+
char *errcopy = err ? pstrdup(err) : "out of memory";
250+
251+
PQfreemem(err);
247252
ereport(ERROR,
248253
(errcode(ERRCODE_SYNTAX_ERROR),
249-
errmsg("invalid connection string syntax: %s", err)));
254+
errmsg("invalid connection string syntax: %s", errcopy)));
255+
}
250256

251257
PQconninfoFree(opts);
252258
}

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