Re: Report a potential memory leak in setup_config()

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: wliang(at)stu(dot)xidian(dot)edu(dot)cn
Cc: pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Report a potential memory leak in setup_config()
Date: 2022-02-15 12:10:45
Message-ID: A7070803-5A15-486E-AE04-ECC13CD10038@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> On 15 Feb 2022, at 02:49, wliang(at)stu(dot)xidian(dot)edu(dot)cn wrote:

> Specifically, at line 1095, function pretty_wal_size() is called, which allocates a chunk of memory by using pg_malloc and returns it. However, the return chunk is directly passed to snprintf as its 3rd parameter. As a result, there is a memory leak.

PostgreSQL isn't all too concerned about small static leaks in short lived
programs, like initdb. Memory will be freed shortly when the program exits.
Complicating the code to save 28 bytes seems hardly worth it, but if you feel
strongly about it I suggest proposing a patch to fix it.

--
Daniel Gustafsson https://vmware.com/

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Troy Frericks 2022-02-15 14:33:26 Re: A bug with the TimeStampTZ data type and the 'AT TIME ZONE' clause
Previous Message hubert depesz lubaczewski 2022-02-15 12:07:05 Re: BUG #17405: Minor upgrade from 12.9 to 12.10 works fine, but PSQL version shows "12.9"