Hi

This is fairly inconsequential as memory leaks goes, but if -D is used when starting postgres, the memory allocated by stdrup() will never be freed. Found with valgrind.

Technically, this also happens with output_config_variable (-C), but since postmaster prints and exits with that, there isn't much point in fixing it.


  best regards, Henrik
From 78a88ba10f8f6aea2b4ccf831ab6775bae68603c Mon Sep 17 00:00:00 2001
From: Henrik TJ <[email protected]>
Date: Wed, 18 Feb 2026 15:28:52 +0100
Subject: [PATCH] Fix userDoption not getting freed in postmaster

---
 src/backend/postmaster/postmaster.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/backend/postmaster/postmaster.c 
b/src/backend/postmaster/postmaster.c
index 3fac46c402b..7480c28f08e 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -784,6 +784,8 @@ PostmasterMain(int argc, char *argv[])
         */
        if (!SelectConfigFiles(userDoption, progname))
                ExitPostmaster(2);
+       if (userDoption != NULL)
+               free(userDoption);
 
        if (output_config_variable != NULL)
        {
-- 
2.53.0

Reply via email to