aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-07-27 20:38:44 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-07-27 20:38:44 +0300
commitd7fd22a38ff48372c6813983317fc8d1e07fcf87 (patch)
treedb01e1a44e9d7f307b397a77833a351fd7d2ba93 /src
parent820d1ced1b308702b3f811647810b4030f974d89 (diff)
downloadpostgresql-d7fd22a38ff48372c6813983317fc8d1e07fcf87.tar.gz
postgresql-d7fd22a38ff48372c6813983317fc8d1e07fcf87.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_rewind/libpq_fetch.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c
index 1979fbcb8a5..0e186f2c36f 100644
--- a/src/bin/pg_rewind/libpq_fetch.c
+++ b/src/bin/pg_rewind/libpq_fetch.c
@@ -350,6 +350,8 @@ libpqGetFile(const char *filename, size_t *filesize)
memcpy(result, PQgetvalue(res, 0, 0), len);
result[len] = '\0';
+ PQclear(res);
+
pg_log(PG_DEBUG, "fetched file \"%s\", length %d\n", filename, len);
if (filesize)
@@ -410,6 +412,7 @@ libpq_executeFileMap(filemap_t *map)
if (PQresultStatus(res) != PGRES_COMMAND_OK)
pg_fatal("could not create temporary table: %s",
PQresultErrorMessage(res));
+ PQclear(res);
sql = "COPY fetchchunks FROM STDIN";
res = PQexec(conn, sql);
@@ -417,6 +420,7 @@ libpq_executeFileMap(filemap_t *map)
if (PQresultStatus(res) != PGRES_COPY_IN)
pg_fatal("could not send file list: %s",
PQresultErrorMessage(res));
+ PQclear(res);
for (i = 0; i < map->narray; i++)
{
@@ -464,6 +468,7 @@ libpq_executeFileMap(filemap_t *map)
if (PQresultStatus(res) != PGRES_COMMAND_OK)
pg_fatal("unexpected result while sending file list: %s",
PQresultErrorMessage(res));
+ PQclear(res);
}
/*