Skip to content

Commit c033569

Browse files
committed
Fix minor memory leak in pg_basebackup and pg_receivewal
The result of the query used to retrieve the WAL segment size from the backend was not getting freed in two code paths. Both pg_basebackup and pg_receivewal exit immediately if a failure happened on this query, so this was not an actual problem, but it could be an issue if this code gets used for other tools in different ways, be they future tools in this code tree or external, existing, ones. Oversight in commit fc49e24, so backpatch down to 11. Author: Jie Zhang Discussion: https://postgr.es/m/970ad9508461469b9450b64027842331@G08CNEXMBPEKD06.g08.fujitsu.local Backpatch-through: 11
1 parent 687e566 commit c033569

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/bin/pg_basebackup/streamutil.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,12 @@ RetrieveWalSegSize(PGconn *conn)
315315
if (sscanf(PQgetvalue(res, 0, 0), "%d%s", &xlog_val, xlog_unit) != 2)
316316
{
317317
pg_log_error("WAL segment size could not be parsed");
318+
PQclear(res);
318319
return false;
319320
}
320321

322+
PQclear(res);
323+
321324
/* set the multiplier based on unit to convert xlog_val to bytes */
322325
if (strcmp(xlog_unit, "MB") == 0)
323326
multiplier = 1024 * 1024;
@@ -336,7 +339,6 @@ RetrieveWalSegSize(PGconn *conn)
336339
return false;
337340
}
338341

339-
PQclear(res);
340342
return true;
341343
}
342344

0 commit comments

Comments
 (0)