avoid-resource-leak-pg_resetwal.patch

application/octet-stream

Filename: avoid-resource-leak-pg_resetwal.patch
Type: application/octet-stream
Part: 0
Message: Avoid resource leak (src/bin/pg_resetwal/pg_resetwal.c)

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
File+
src/bin/pg_resetwal/pg_resetwal.c 3 0
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
index a89d72fc5c..ca8eaf86ad 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -613,6 +613,8 @@ read_controlfile(void)
 
 		memcpy(&ControlFile, buffer, sizeof(ControlFile));
 
+		pg_free(buffer);
+
 		/* return false if WAL segment size is not valid */
 		if (!IsValidWalSegSize(ControlFile.xlog_seg_size))
 		{
@@ -625,6 +627,7 @@ read_controlfile(void)
 
 		return true;
 	}
+	pg_free(buffer);
 
 	/* Looks like it's a mess. */
 	pg_log_warning("pg_control exists but is broken or wrong version; ignoring it");