Re: BUG #6672: Memory leaks in dumputils.c - Mailing list pgsql-bugs

From Josh Kupershmidt
Subject Re: BUG #6672: Memory leaks in dumputils.c
Date
Msg-id CAK3UJREivjfksWk2KZZMNR3OgEpPvt+RT=ARhQhF9GxkDo7+SQ@mail.gmail.com
Whole thread Raw
In response to Re: BUG #6672: Memory leaks in dumputils.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #6672: Memory leaks in dumputils.c
Re: BUG #6672: Memory leaks in dumputils.c
List pgsql-bugs
On Thu, May 31, 2012 at 10:06 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> zaks.anna@gmail.com writes:

>> There are two memory leaks in dumputils (v9.2.0beta1):
>
>> 1)
>> File:   src/bin/scripts/dumputils.c
>> Location:       line 604, column 11
>> Description:    Memory is never released; potential leak of memory
>> pointed to by 'aclitems'
>
>> 2)
>> File:   src/bin/scripts/dumputils.c
>> Location:       line 793, column 10
>> Description:    Memory is never released; potential leak of memory
>> pointed to by 'eqpos'
>
> This is a remarkably unhelpful report.  I do not see any memory
> allocation occurring on either line 604 or line 793 of dumputils.c,
> in either 9.2beta1 or 9.1.3.  Could you perhaps provide source code
> extracts rather than line numbers that reference indeterminate versions
> of files?

I suspect the first complaint is about this bit in git head's
./src/bin/pg_dump/dumputils.c:

        if (!parseAclItem(aclitems[i], type, name, subname, remoteVersion,
                          grantee, grantor, privs, privswgo))
            return false;

since 'aclitems' isn't being freed before the return. And the second
complaint seems to concern parseAclItem() not freeing 'buf' when it
returns false. Both of these errors seem academic, since the callers
of buildACLCommands() will bail out with exit_horribly() or
exit_nicely() if it returns false. But IMO it's worth fixing anyway,
to keep the compilers happy or in case of future code calling
buildACLCommands() or parseAclItem().

Attached is a patch to hopefully fix those two errors. I couldn't
quite verify this fixes the OP's error messages, since "checker-266"
isn't done running make after several hours on this OS X machine.

Josh

Attachment

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #6666: pg_upgrade 9.2beta1 plpython/plpython2
Next
From: Josh Kupershmidt
Date:
Subject: Re: BUG #6672: Memory leaks in dumputils.c