]> granicus.if.org Git - postgresql/commitdiff
Don't leak memory after connection aborts in pg_recvlogical.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 5 May 2014 13:20:12 +0000 (16:20 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 5 May 2014 13:20:12 +0000 (16:20 +0300)
Andres Freund, noticed by coverity.

src/bin/pg_basebackup/pg_recvlogical.c

index 8141ba31f9d16ce9416de9e98ada4dc23fca8419..fe902cf9691b051de3b3a26cf31e70543c45aac7 100644 (file)
@@ -547,9 +547,6 @@ StreamLog(void)
        }
        PQclear(res);
 
-       if (copybuf != NULL)
-               PQfreemem(copybuf);
-
        if (outfd != -1 && strcmp(outfile, "-") != 0)
        {
                int64 t = feGetCurrentTimestamp();
@@ -563,6 +560,11 @@ StreamLog(void)
        }
        outfd = -1;
 error:
+       if (copybuf != NULL)
+       {
+               PQfreemem(copybuf);
+               copybuf = NULL;
+       }
        destroyPQExpBuffer(query);
        PQfinish(conn);
        conn = NULL;