From 17b04a15806d8e8b4cc3013244f4837c02d6baf4 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 6 May 2014 15:14:51 +0300 Subject: [PATCH] Fix use of free in walsender error handling after a sysid mismatch. Found via valgrind. The bug exists since the introduction of the walsender, so backpatch to 9.0. Andres Freund --- src/backend/replication/libpqwalreceiver/libpqwalreceiver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c index 979b66b300a..5340ed064cf 100644 --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c @@ -135,6 +135,7 @@ libpqrcv_connect(char *conninfo, XLogRecPtr startpoint) GetSystemIdentifier()); if (strcmp(primary_sysid, standby_sysid) != 0) { + primary_sysid = pstrdup(primary_sysid); PQclear(res); ereport(ERROR, (errmsg("database system identifier differs between the primary and standby"),