| From: | "Zhang, Jie" <zhangjie2(at)cn(dot)fujitsu(dot)com> |
|---|---|
| To: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | "Zhang, Jie" <zhangjie2(at)cn(dot)fujitsu(dot)com> |
| Subject: | [PATHC] Fix minor memory leak in pg_basebackup |
| Date: | 2020-04-15 10:06:52 |
| Message-ID: | 970ad9508461469b9450b64027842331@G08CNEXMBPEKD06.g08.fujitsu.local |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi all
In some cases , PGresult is not cleared.
File: src\bin\pg_basebackup\streamutil.c
bool
RetrieveWalSegSize(PGconn *conn)
{
PGresult *res;
......
res = PQexec(conn, "SHOW wal_segment_size");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
pg_log_error("could not send replication command \"%s\": %s",
"SHOW wal_segment_size", PQerrorMessage(conn));
PQclear(res); // *** res is cleared ***
return false;
}
......
/* fetch xlog value and unit from the result */
if (sscanf(PQgetvalue(res, 0, 0), "%d%s", &xlog_val, xlog_unit) != 2)
{
pg_log_error("WAL segment size could not be parsed");
return false; // *** res is not cleared ***
}
......
if (!IsValidWalSegSize(WalSegSz))
{
pg_log_error(ngettext("WAL segment size must be a power of two between 1 MB and 1 GB, but the remote server reported a value of %d byte",
"WAL segment size must be a power of two between 1 MB and 1 GB, but the remote server reported a value of %d bytes",
WalSegSz),
WalSegSz);
return false; ; // *** res is not cleared ***
}
......
Here is a patch.
Best Regards!
| Attachment | Content-Type | Size |
|---|---|---|
| pg_basebackup.patch | application/octet-stream | 682 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter J. Holzer | 2020-04-15 10:14:25 | Re: pg_restore: could not close data file: Success |
| Previous Message | Peter J. Holzer | 2020-04-15 10:01:46 | pg_restore: could not close data file: Success |