aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Frost <sfrost@snowman.net>2017-05-06 22:58:12 -0400
committerStephen Frost <sfrost@snowman.net>2017-05-06 22:58:12 -0400
commit09f842181943b6e83b0779f2e872ff0180b66883 (patch)
tree9d13bca0be3e52486e21b15918ffd9bfe7def8a8
parentaa5d3c0b3fb906dfa910b0ca6f75ab701b2f1c09 (diff)
downloadpostgresql-09f842181943b6e83b0779f2e872ff0180b66883.tar.gz
postgresql-09f842181943b6e83b0779f2e872ff0180b66883.zip
pg_dump: Don't leak memory in buildDefaultACLCommands()
buildDefaultACLCommands() didn't destroy the string buffer created in certain cases, leading to a memory leak. Fix by destroying the buffer before returning from the function. Spotted by Coverity. Author: Michael Paquier Back-patch to 9.6 where buildDefaultACLCommands() was added.
-rw-r--r--src/bin/pg_dump/dumputils.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index c74153acce2..19534248ab7 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -390,13 +390,19 @@ buildDefaultACLCommands(const char *type, const char *nspname,
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
if (!buildACLCommands("", NULL, type, initacls, initracls, owner,
prefix->data, remoteVersion, sql))
+ {
+ destroyPQExpBuffer(prefix);
return false;
+ }
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
}
if (!buildACLCommands("", NULL, type, acls, racls, owner,
prefix->data, remoteVersion, sql))
+ {
+ destroyPQExpBuffer(prefix);
return false;
+ }
destroyPQExpBuffer(prefix);