diff --git a/src/bin/pg_basebackup/pg_receivewal.c b/src/bin/pg_basebackup/pg_receivewal.c
index 176c40faca..69d279edea 100644
--- a/src/bin/pg_basebackup/pg_receivewal.c
+++ b/src/bin/pg_basebackup/pg_receivewal.c
@@ -547,6 +547,7 @@ StreamLog(void)
 			if (!GetSlotInformation(conn, replication_slot, &stream.startpos,
 									&stream.timeline))
 			{
+				pg_free(sysidentifier);
 				/* Error is logged by GetSlotInformation() */
 				return;
 			}
