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

Commit d73b7f9

Browse files
committed
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
1 parent 8fcbfea commit d73b7f9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/bin/pg_dump/dumputils.c

+9
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,10 @@ buildACLCommands(const char *name, const char *subname,
600600
{
601601
if (!parseAclItem(aclitems[i], type, name, subname, remoteVersion,
602602
grantee, grantor, privs, privswgo))
603+
{
604+
free(aclitems);
603605
return false;
606+
}
604607

605608
if (grantor->len == 0 && owner)
606609
printfPQExpBuffer(grantor, "%s", owner);
@@ -789,7 +792,10 @@ parseAclItem(const char *item, const char *type,
789792
/* user or group name is string up to = */
790793
eqpos = copyAclUserName(grantee, buf);
791794
if (*eqpos != '=')
795+
{
796+
free(buf);
792797
return false;
798+
}
793799

794800
/* grantor may be listed after / */
795801
slpos = strchr(eqpos + 1, '/');
@@ -798,7 +804,10 @@ parseAclItem(const char *item, const char *type,
798804
*slpos++ = '\0';
799805
slpos = copyAclUserName(grantor, slpos);
800806
if (*slpos != '\0')
807+
{
808+
free(buf);
801809
return false;
810+
}
802811
}
803812
else
804813
resetPQExpBuffer(grantor);

0 commit comments

Comments
 (0)