Skip to content

Commit 8b63f89

Browse files
committed
Fix more memory leaks in failure path in buildACLCommands.
We already had one go at this issue in commit d73b7f9, 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.
1 parent 9be9ac4 commit 8b63f89

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/bin/pg_dump/dumputils.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ buildACLCommands(const char *name, const char *subname,
531531
const char *prefix, int remoteVersion,
532532
PQExpBuffer sql)
533533
{
534+
bool ok = true;
534535
char **aclitems;
535536
int naclitems;
536537
int i;
@@ -601,8 +602,8 @@ buildACLCommands(const char *name, const char *subname,
601602
if (!parseAclItem(aclitems[i], type, name, subname, remoteVersion,
602603
grantee, grantor, privs, privswgo))
603604
{
604-
free(aclitems);
605-
return false;
605+
ok = false;
606+
break;
606607
}
607608

608609
if (grantor->len == 0 && owner)
@@ -709,7 +710,7 @@ buildACLCommands(const char *name, const char *subname,
709710

710711
free(aclitems);
711712

712-
return true;
713+
return ok;
713714
}
714715

715716
/*

0 commit comments

Comments
 (0)