public inbox for [email protected]
help / color / mirror / Atom feedFrom: Henrik TJ <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: Fix memory leak in postmasterMain
Date: Sat, 21 Feb 2026 15:27:15 +0100 (CET)
Message-ID: <[email protected]> (raw)
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
Attachments:
[text/plain] v1-0001-Fix-userDoption-not-getting-freed-in-postmaster.patch (765B, 2-v1-0001-Fix-userDoption-not-getting-freed-in-postmaster.patch)
download | inline diff:
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
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: Fix memory leak in postmasterMain
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox