RE: [PATHC] Fix minor memory leak in pg_basebackup

From: "Zhang, Jie" <zhangjie2(at)cn(dot)fujitsu(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
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 10:54:09
Message-ID: 343665364037409dafcda21e96c6d9f4@G08CNEXMBPEKD06.g08.fujitsu.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Michael

so much the better!

-----Original Message-----
From: Michael Paquier [mailto:michael(at)paquier(dot)xyz]
Sent: Thursday, April 16, 2020 2:31 PM
To: Zhang, Jie/张 杰 <zhangjie2(at)cn(dot)fujitsu(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATHC] Fix minor memory leak in pg_basebackup

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2020-04-16 12:17:33 Making openssl_tls_init_hook OpenSSL specific
Previous Message Richard Guo 2020-04-16 10:35:20 Re: sqlsmith crash incremental sort