From: Tofig Aliev <t.aliev@postgrespro.ru>
To: pgsql-hackers@lists.postgresql.org
To: sawada.mshk@gmail.com
Subject: Fix tiny memory leaks
Date: Fri, 06 Dec 2024 15:38:35 +0700
Message-ID: <bba4313fdde9db46db279f96f3b748b1@postgrespro.ru> (raw)
Hi, hackers!
There is a memory leak in functions check_application_name() and
check_cluster_name().
Functions are located in src/backend/commands/variable.c
The leak can be triggered using SQL command: SET
application_name=new_name;
You can run pgbench with this command for a long time by passing this
command in file via '-f' flag.
regards,
Tofig
Attachments:0001-Fix-tiny-memory-leaks.patch (text/x-diff, 1019B) download
From a801d03c57819d3de181967d72260cb42bbcf6a3 Mon Sep 17 00:00:00 2001
From: Tofig Aliev <t.aliev@postgrespro.ru>
Date: Fri, 6 Dec 2024 14:58:38 +0700
Subject: [PATCH] Fix tiny memory leaks
Memory for (*newval) allocated earlier
in the parse_and_validate_value() method.
Since this method re-allocates memory,
it is necessary to free the previously allocated memory.
---
src/backend/commands/variable.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.cindex 0ecff94d0e..2c8059e8d8 100644--- a/src/backend/commands/variable.c+++ b/src/backend/commands/variable.c@@ -1092,6 +1092,8 @@ check_application_name(char **newval, void **extra, GucSource source)
return false;
}
+ guc_free(*newval);+
pfree(clean);
*newval = ret;
return true;
@@ -1128,6 +1130,8 @@ check_cluster_name(char **newval, void **extra, GucSource source)
return false;
}
+ guc_free(*newval);+
pfree(clean);
*newval = ret;
return true;
--
2.43.0
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: pgsql-hackers@postgresql.org
Cc: t.aliev@postgrespro.ru, pgsql-hackers@lists.postgresql.org, sawada.mshk@gmail.com
Subject: Re: Fix tiny memory leaks
In-Reply-To: <bba4313fdde9db46db279f96f3b748b1@postgrespro.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox