Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9179444

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 9feefed commit 9179444

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/bin/pg_dump/dumputils.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ buildACLCommands(const char *name, const char *subname,
500500
const char *prefix, int remoteVersion,
501501
PQExpBuffer sql)
502502
{
503+
bool ok = true;
503504
char **aclitems;
504505
int naclitems;
505506
int i;
@@ -570,8 +571,8 @@ buildACLCommands(const char *name, const char *subname,
570571
if (!parseAclItem(aclitems[i], type, name, subname, remoteVersion,
571572
grantee, grantor, privs, privswgo))
572573
{
573-
free(aclitems);
574-
return false;
574+
ok = false;
575+
break;
575576
}
576577

577578
if (grantor->len == 0 && owner)
@@ -678,7 +679,7 @@ buildACLCommands(const char *name, const char *subname,
678679

679680
free(aclitems);
680681

681-
return true;
682+
return ok;
682683
}
683684

684685
/*

0 commit comments

Comments
 (0)