Fix memory leaks in pg_rewind. Several PQclear() calls were missing.
Originally reported by Vladimir Borodin in the pg_rewind github project, patch by Michael Paquier.
This commit is contained in:
parent
820d1ced1b
commit
d7fd22a38f
|
@ -350,6 +350,8 @@ libpqGetFile(const char *filename, size_t *filesize)
|
||||||
memcpy(result, PQgetvalue(res, 0, 0), len);
|
memcpy(result, PQgetvalue(res, 0, 0), len);
|
||||||
result[len] = '\0';
|
result[len] = '\0';
|
||||||
|
|
||||||
|
PQclear(res);
|
||||||
|
|
||||||
pg_log(PG_DEBUG, "fetched file \"%s\", length %d\n", filename, len);
|
pg_log(PG_DEBUG, "fetched file \"%s\", length %d\n", filename, len);
|
||||||
|
|
||||||
if (filesize)
|
if (filesize)
|
||||||
|
@ -410,6 +412,7 @@ libpq_executeFileMap(filemap_t *map)
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
pg_fatal("could not create temporary table: %s",
|
pg_fatal("could not create temporary table: %s",
|
||||||
PQresultErrorMessage(res));
|
PQresultErrorMessage(res));
|
||||||
|
PQclear(res);
|
||||||
|
|
||||||
sql = "COPY fetchchunks FROM STDIN";
|
sql = "COPY fetchchunks FROM STDIN";
|
||||||
res = PQexec(conn, sql);
|
res = PQexec(conn, sql);
|
||||||
|
@ -417,6 +420,7 @@ libpq_executeFileMap(filemap_t *map)
|
||||||
if (PQresultStatus(res) != PGRES_COPY_IN)
|
if (PQresultStatus(res) != PGRES_COPY_IN)
|
||||||
pg_fatal("could not send file list: %s",
|
pg_fatal("could not send file list: %s",
|
||||||
PQresultErrorMessage(res));
|
PQresultErrorMessage(res));
|
||||||
|
PQclear(res);
|
||||||
|
|
||||||
for (i = 0; i < map->narray; i++)
|
for (i = 0; i < map->narray; i++)
|
||||||
{
|
{
|
||||||
|
@ -464,6 +468,7 @@ libpq_executeFileMap(filemap_t *map)
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
pg_fatal("unexpected result while sending file list: %s",
|
pg_fatal("unexpected result while sending file list: %s",
|
||||||
PQresultErrorMessage(res));
|
PQresultErrorMessage(res));
|
||||||
|
PQclear(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue