From: Heikki Linnakangas Date: Tue, 6 May 2014 12:14:51 +0000 (+0300) Subject: Fix use of free in walsender error handling after a sysid mismatch. X-Git-Tag: REL9_3_5~79 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7a3e71c8592a530f9a605aea4f08af7ad8e0ab3;p=thirdparty%2Fpostgresql.git 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 --- diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c index 6bc0aa1c12c..1cb2c6e524d 100644 --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c @@ -151,6 +151,7 @@ libpqrcv_identify_system(TimeLineID *primary_tli) 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"),