Commit d73b7f97 authored by Tom Lane's avatar Tom Lane

Fix memory leaks in failure paths in buildACLCommands and parseAclItem.

This is currently only cosmetic, since all the call sites just curl up
and die in event of a failure return.  It might be important for some
future use-case, though, and in any case it quiets warnings from the
clang static analyzer (as reported by Anna Zaks).

Josh Kupershmidt
parent 8fcbfea7
...@@ -600,7 +600,10 @@ buildACLCommands(const char *name, const char *subname, ...@@ -600,7 +600,10 @@ 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);
return false; return false;
}
if (grantor->len == 0 && owner) if (grantor->len == 0 && owner)
printfPQExpBuffer(grantor, "%s", owner); printfPQExpBuffer(grantor, "%s", owner);
...@@ -789,7 +792,10 @@ parseAclItem(const char *item, const char *type, ...@@ -789,7 +792,10 @@ parseAclItem(const char *item, const char *type,
/* user or group name is string up to = */ /* user or group name is string up to = */
eqpos = copyAclUserName(grantee, buf); eqpos = copyAclUserName(grantee, buf);
if (*eqpos != '=') if (*eqpos != '=')
{
free(buf);
return false; return false;
}
/* grantor may be listed after / */ /* grantor may be listed after / */
slpos = strchr(eqpos + 1, '/'); slpos = strchr(eqpos + 1, '/');
...@@ -798,7 +804,10 @@ parseAclItem(const char *item, const char *type, ...@@ -798,7 +804,10 @@ parseAclItem(const char *item, const char *type,
*slpos++ = '\0'; *slpos++ = '\0';
slpos = copyAclUserName(grantor, slpos); slpos = copyAclUserName(grantor, slpos);
if (*slpos != '\0') if (*slpos != '\0')
{
free(buf);
return false; return false;
}
} }
else else
resetPQExpBuffer(grantor); resetPQExpBuffer(grantor);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment