0001-Fix-memory-leak-of-reply_message-in-walreceiver.patch

text/x-patch

Filename: 0001-Fix-memory-leak-of-reply_message-in-walreceiver.patch
Type: text/x-patch
Part: 0
Message: [PATCH] Fix memory leak of reply_message in walreceiver

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
Series: patch 0001
File+
src/backend/replication/walreceiver.c 3 2
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 8185412a810..23fce948967 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -302,6 +302,8 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
 	if (sender_host)
 		pfree(sender_host);
 
+	initStringInfo(&reply_message);
+
 	first_stream = true;
 	for (;;)
 	{
@@ -405,9 +407,8 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
 				walrcv->walRcvState = WALRCV_STREAMING;
 			SpinLockRelease(&walrcv->mutex);
 
-			/* Initialize LogstreamResult and buffers for processing messages */
+			/* Initialize LogstreamResult for processing messages */
 			LogstreamResult.Write = LogstreamResult.Flush = GetXLogReplayRecPtr(NULL);
-			initStringInfo(&reply_message);
 
 			/* Initialize nap wakeup times. */
 			now = GetCurrentTimestamp();