Re: [PATHC] Fix minor memory leak in pg_basebackup

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: "Zhang, Jie" <zhangjie2(at)cn(dot)fujitsu(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATHC] Fix minor memory leak in pg_basebackup
Date: 2020-04-16 06:30:36
Message-ID: 20200416063036.GC81957@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 15, 2020 at 10:06:52AM +0000, Zhang, Jie wrote:
> In some cases , PGresult is not cleared.
>
> File: src\bin\pg_basebackup\streamutil.c
>
> bool
> RetrieveWalSegSize(PGconn *conn)
> {
> PGresult *res;

RetrieveWalSegSize() gets called only once at the beginning of
pg_basebackup and pg_receivewal, so that's not an issue that has major
effects, still that's an issue. The first one PQclear() is needed
where you say. Now for the second one, I would just move it once the
code is done with the query result, aka after calling PQgetvalue().
What do you think? Please see the attached.
--
Michael

Attachment Content-Type Size
basebackup-leak.patch text/x-diff 695 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Khandekar 2020-04-16 07:18:18 Re: spin_delay() for ARM
Previous Message Pierre Giraud 2020-04-16 06:26:54 Re: Poll: are people okay with function/operator table redesign?