unitialized_variable_warning.patch.txt

text/plain

Filename: unitialized_variable_warning.patch.txt
Type: text/plain
Part: 0
Message: Re: Changing shared_buffers without restart
commit 5c54d36d28edcdd72edd6374132ac88e1693fcaa
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date:   Wed Jul 2 15:47:45 2025 +0530

    fixup! Allow to use multiple shared memory mappings
    
    shm_total_page_count is used unitialized. If this variable has a random
    value to start with, the final sum would be wrong.
    
    Ashutosh Bapat

diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c
index 9dd22920a79..24aec528c3c 100644
--- a/src/backend/storage/ipc/shmem.c
+++ b/src/backend/storage/ipc/shmem.c
@@ -658,7 +658,7 @@ pg_get_shmem_allocations_numa(PG_FUNCTION_ARGS)
 	Size		os_page_size;
 	void	  **page_ptrs;
 	int		   *pages_status;
-	uint64		shm_total_page_count,
+	uint64		shm_total_page_count = 0,
 				shm_ent_page_count,
 				max_nodes;
 	Size	   *nodes;