diff options
author | Stephen Frost <sfrost@snowman.net> | 2017-05-06 22:58:22 -0400 |
---|---|---|
committer | Stephen Frost <sfrost@snowman.net> | 2017-05-06 22:58:22 -0400 |
commit | ef42c1103708cbbb77fff674f339d452a13aac14 (patch) | |
tree | 1d0c55ca26043928ad52b8df8fdc3e2805697984 | |
parent | 92b15224b4eac8eeae0616491ccf0c852fa2dff9 (diff) | |
download | postgresql-ef42c1103708cbbb77fff674f339d452a13aac14.tar.gz postgresql-ef42c1103708cbbb77fff674f339d452a13aac14.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.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index a062a6b3301..11870a33fa5 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -394,13 +394,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); |