Re: pg_dump: fix memory leak - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: pg_dump: fix memory leak
Date
Msg-id 9A56B32D-14F3-4EF0-A3B7-7065D7B5B53D@yesql.se
Whole thread Raw
In response to pg_dump: fix memory leak  (m.korotkov@postgrespro.ru)
Responses Re: pg_dump: fix memory leak
Re: pg_dump: fix memory leak
List pgsql-hackers
> On 28 Aug 2025, at 16:14, m.korotkov@postgrespro.ru wrote:
>
> Hi all,
> I have found a potential memory leak in src/bin/pg_dump/dumputils.c in the function generate_restrict_key().
> Memory is allocated to the ret pointer if pg_strong_random returns false, and this leads to a memory leak.
> I have replaced the allocation to avoid this leak.

This is not actually a leak since the application will terminate immediately if
a restrict key cannot be generated.  If you inspect the callsites you will see
this pattern:

    if (!restrict_key)
        restrict_key = generate_restrict_key();
    if (!restrict_key)
        pg_fatal("could not generate restrict key");

--
Daniel Gustafsson




pgsql-hackers by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Re: Improve LWLock tranche name visibility across backends
Next
From: Andrey Borodin
Date:
Subject: Re: IPC/MultixactCreation on the Standby server