RE: [PATHC] Fix minor memory leak in pg_basebackup
Zhang, Jie <zhangjie2@cn.fujitsu.com>
From: "Zhang, Jie" <zhangjie2@cn.fujitsu.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2020-04-16T10:54:09Z
Lists: pgsql-hackers
Hi Michael
so much the better!
-----Original Message-----
From: Michael Paquier [mailto:michael@paquier.xyz]
Sent: Thursday, April 16, 2020 2:31 PM
To: Zhang, Jie/张 杰 <zhangjie2@cn.fujitsu.com>
Cc: pgsql-hackers@lists.postgresql.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
Commits
-
Fix minor memory leak in pg_basebackup and pg_receivewal
- 213e2b7363cd 11.8 landed
- c03356995f86 12.3 landed
- 198efe774b0d 13.0 landed