Fix double-free bug of WAL streaming buffer in pg_receivexlog.
authorFujii Masao <fujii@postgresql.org>
Fri, 4 Jul 2014 10:48:38 +0000 (19:48 +0900)
committerFujii Masao <fujii@postgresql.org>
Fri, 4 Jul 2014 10:48:38 +0000 (19:48 +0900)
This bug was introduced while refactoring in commit 74cbe96.

src/bin/pg_basebackup/receivelog.c

index 4aa35da2fce359d4e735a00ed37cb744c69ff781..97a078526a3802687db7e2551830f15e8d2b44d5 100644 (file)
@@ -1079,12 +1079,11 @@ CopyStreamPoll(PGconn *conn, long timeout_ms)
 static int
 CopyStreamReceive(PGconn *conn, long timeout, char **buffer)
 {
-   static char    *copybuf = NULL;
+   char       *copybuf = NULL;
    int         rawlen;
 
-   if (copybuf != NULL)
-       PQfreemem(copybuf);
-   copybuf = NULL;
+   if (*buffer != NULL)
+       PQfreemem(*buffer);
    *buffer = NULL;
 
    /* Try to receive a CopyData message */