From e97121b2aef851f89910c93f7a9cded3aa4b8ff4 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Thu, 11 Dec 2025 11:42:54 +0800
Subject: [PATCH v1] Fix uninitialized PruneFreezeResult in pruneheap and
 vacuumlazy

heap_page_prune_opt() and lazy_scan_prune() each declared a local
PruneFreezeResult variable without initializing it.  Most fields are
filled in by heap_page_prune_and_freeze(), but it immedately call
prune_freeze_setup() that will access presult->deadoffsets, and
the field could hold a random as *presult is not initialized.

Initialize the local PruneFreezeResult instances with = {0} to ensure
all fields start in a known state.

No behavioral change is intended aside from eliminating use of
uninitialized memory.

Author: Chao Li <lic@highgo.com>
---
 src/backend/access/heap/pruneheap.c  | 2 +-
 src/backend/access/heap/vacuumlazy.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
index ca44225a10e..61ff79e9eb8 100644
--- a/src/backend/access/heap/pruneheap.c
+++ b/src/backend/access/heap/pruneheap.c
@@ -269,7 +269,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
 		if (PageIsFull(page) || PageGetHeapFreeSpace(page) < minfree)
 		{
 			OffsetNumber dummy_off_loc;
-			PruneFreezeResult presult;
+			PruneFreezeResult presult = {0};
 
 			/*
 			 * We don't pass the HEAP_PAGE_PRUNE_MARK_UNUSED_NOW option
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index e8c99c3773d..786778f6e0a 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -1978,7 +1978,7 @@ lazy_scan_prune(LVRelState *vacrel,
 				bool *vm_page_frozen)
 {
 	Relation	rel = vacrel->rel;
-	PruneFreezeResult presult;
+	PruneFreezeResult presult = {0};
 	PruneFreezeParams params = {
 		.relation = rel,
 		.buffer = buf,
-- 
2.39.5 (Apple Git-154)

