Fix use of free in walsender error handling after a sysid mismatch.
authorHeikki Linnakangas <[email protected]>
Tue, 6 May 2014 12:14:51 +0000 (15:14 +0300)
committerHeikki Linnakangas <[email protected]>
Tue, 6 May 2014 12:17:14 +0000 (15:17 +0300)
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

index 8f1c592f48bdf1c8e57a1ad00086b551d8909374..d2786fdf8b0db21a4997019bbaee5d5b41a71d01 100644 (file)
@@ -133,6 +133,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"),