Skip to content

Commit 329de9f

Browse files
committed
Don't leak memory after connection aborts in pg_recvlogical.
Andres Freund, noticed by coverity.
1 parent c834576 commit 329de9f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/bin/pg_basebackup/pg_recvlogical.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,6 @@ StreamLog(void)
547547
}
548548
PQclear(res);
549549

550-
if (copybuf != NULL)
551-
PQfreemem(copybuf);
552-
553550
if (outfd != -1 && strcmp(outfile, "-") != 0)
554551
{
555552
int64 t = feGetCurrentTimestamp();
@@ -563,6 +560,11 @@ StreamLog(void)
563560
}
564561
outfd = -1;
565562
error:
563+
if (copybuf != NULL)
564+
{
565+
PQfreemem(copybuf);
566+
copybuf = NULL;
567+
}
566568
destroyPQExpBuffer(query);
567569
PQfinish(conn);
568570
conn = NULL;

0 commit comments

Comments
 (0)