Re: BUG #6672: Memory leaks in dumputils.c

From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: zaks(dot)anna(at)gmail(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6672: Memory leaks in dumputils.c
Date: 2012-06-01 18:13:23
Message-ID: CAK3UJREivjfksWk2KZZMNR3OgEpPvt+RT=ARhQhF9GxkDo7+SQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, May 31, 2012 at 10:06 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> zaks(dot)anna(at)gmail(dot)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 Content-Type Size
dumputils_clang.diff application/octet-stream 1.7 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Anna Zaks 2012-06-01 18:38:19 Re: BUG #6672: Memory leaks in dumputils.c
Previous Message Anna Zaks 2012-06-01 17:17:48 Re: BUG #6672: Memory leaks in dumputils.c