summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-02-11 18:35:23 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2015-02-11 18:35:23 -0500
commit8b63f89498f2e3ff0e1d420b023ccb76c34c2cda (patch)
tree67c6f8d7732bd5bf283769bc33233e706b96e03b
parent9be9ac4254cf32e98980ad89320e4e8b0ca515a7 (diff)
Fix more memory leaks in failure path in buildACLCommands.
We already had one go at this issue in commit d73b7f973db5ec7e, but we failed to notice that buildACLCommands also leaked several PQExpBuffers along with a simply malloc'd string. This time let's try to make the fix a bit more future-proof by eliminating the separate exit path. It's still not exactly critical because pg_dump will curl up and die on failure; but since the amount of the potential leak is now several KB, it seems worth back-patching as far as 9.2 where the previous fix landed. Per Coverity, which evidently is smarter than clang's static analyzer.
-rw-r--r--src/bin/pg_dump/dumputils.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index a92e4dcd609..b4edf216740 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -531,6 +531,7 @@ buildACLCommands(const char *name, const char *subname,
const char *prefix, int remoteVersion,
PQExpBuffer sql)
{
+ bool ok = true;
char **aclitems;
int naclitems;
int i;
@@ -601,8 +602,8 @@ buildACLCommands(const char *name, const char *subname,
if (!parseAclItem(aclitems[i], type, name, subname, remoteVersion,
grantee, grantor, privs, privswgo))
{
- free(aclitems);
- return false;
+ ok = false;
+ break;
}
if (grantor->len == 0 && owner)
@@ -709,7 +710,7 @@ buildACLCommands(const char *name, const char *subname,
free(aclitems);
- return true;
+ return ok;
}
/*