Hi all,
After a run of valgrind on pg_rewind, I found a couple of code paths
missing some PQclear calls after running a query. Attached is a patch
to fix all those leaks.
Regards,
--
Michael
diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c
index 1979fbc..c670fe2 100644
--- a/src/bin/pg_rewind/libpq_fetch.c
+++ b/src/bin/pg_rewind/libpq_fetch.c
@@ -352,6 +352,8 @@ libpqGetFile(const char *filename, size_t *filesize)
pg_log(PG_DEBUG, "fetched file \"%s\", length %d\n", filename, len);
+ PQclear(res);
+
if (filesize)
*filesize = len;
return result;
@@ -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);
@@ -455,6 +458,8 @@ libpq_executeFileMap(filemap_t *map)
}
}
+ PQclear(res);
+
if (PQputCopyEnd(conn, NULL) != 1)
pg_fatal("could not send end-of-COPY: %s",
PQerrorMessage(conn));
@@ -464,6 +469,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);
}
/*
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers