mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
Fix more memory leaks in failure path in buildACLCommands.
We already had one go at this issue in commit d73b7f973d
, 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.
This commit is contained in:
@ -500,6 +500,7 @@ buildACLCommands(const char *name, const char *subname,
|
|||||||
const char *prefix, int remoteVersion,
|
const char *prefix, int remoteVersion,
|
||||||
PQExpBuffer sql)
|
PQExpBuffer sql)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
char **aclitems;
|
char **aclitems;
|
||||||
int naclitems;
|
int naclitems;
|
||||||
int i;
|
int i;
|
||||||
@ -570,8 +571,8 @@ buildACLCommands(const char *name, const char *subname,
|
|||||||
if (!parseAclItem(aclitems[i], type, name, subname, remoteVersion,
|
if (!parseAclItem(aclitems[i], type, name, subname, remoteVersion,
|
||||||
grantee, grantor, privs, privswgo))
|
grantee, grantor, privs, privswgo))
|
||||||
{
|
{
|
||||||
free(aclitems);
|
ok = false;
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grantor->len == 0 && owner)
|
if (grantor->len == 0 && owner)
|
||||||
@ -678,7 +679,7 @@ buildACLCommands(const char *name, const char *subname,
|
|||||||
|
|
||||||
free(aclitems);
|
free(aclitems);
|
||||||
|
|
||||||
return true;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user