From: | Japin Li <japinli(at)hotmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Memory leak in adjust_data_dir |
Date: | 2022-11-16 05:21:33 |
Message-ID: | MEYP282MB1669C1B39D1C5AD1F9B97F9CB6079@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, 16 Nov 2022 at 12:19, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Japin Li <japinli(at)hotmail(dot)com> writes:
>> Hi, hackers,
>
> ITYM pgsql-hackers, this is off-topic here.
>
Sorry for typo the email address.
>> When I'm reviewing patch [1], I find there is a memory leak in
>> adjust_data_dir(), the cmd was allocated by psprintf(), but forget
>> releasing.
>
> Can't get excited about it in pg_ctl; that program won't run
> long enough for anybody to notice.
>
Yeah, it won't run a long time. I find that the memory of my_exec_path
was released, so I think we also should do release on cmd. IMO, this is
a bit confused when should we do release the memory of variables for
short lifetime?
[Here is the origin contents which I send a wrong mail-list]
Hi, hackers,
When I'm reviewing patch [1], I find there is a memory leak in
adjust_data_dir(), the cmd was allocated by psprintf(), but forget
releasing.
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index ceab603c47..ace2d676fc 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -2159,6 +2159,7 @@ adjust_data_dir(void)
write_stderr(_("%s: could not determine the data directory using command \"%s\"\n"), progname, cmd);
exit(1);
}
+ free(cmd);
free(my_exec_path);
/* strip trailing newline and carriage return */
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.
From | Date | Subject | |
---|---|---|---|
Next Message | Julien Rouhaud | 2022-11-16 05:30:39 | Re: Allow file inclusion in pg_hba and pg_ident files |
Previous Message | Andres Freund | 2022-11-16 05:20:23 | Re: New strategies for freezing, advancing relfrozenxid early |