From: Michael Snyder <msnyder@vmware.com>
To: Michael Snyder <msnyder@vmware.com>,
"binutils@sourceware.org" <binutils@sourceware.org>,
richard.sandiford@linaro.org
Subject: Re: [RFA] readelf.c (process_gnu_liblist): Stop memory leak.
Date: Mon, 14 Mar 2011 17:56:00 -0000 [thread overview]
Message-ID: <4D7E56D3.7070508@vmware.com> (raw)
In-Reply-To: <g4tyf53nh0.fsf@linaro.org>
Richard Sandiford wrote:
> Michael Snyder <msnyder@vmware.com> writes:
>> OK?
>>
>> 2011-03-07 Michael Snyder <msnyder@msnyder-server.eng.vmware.com>
>>
>> * readelf.c (process_gnu_liblist): Stop memory leak.
>>
>> Index: readelf.c
>> ===================================================================
>> RCS file: /cvs/src/src/binutils/readelf.c,v
>> retrieving revision 1.534
>> diff -u -p -r1.534 readelf.c
>> --- readelf.c 1 Mar 2011 00:02:32 -0000 1.534
>> +++ readelf.c 8 Mar 2011 01:27:07 -0000
>> @@ -11807,7 +11811,7 @@ process_gnu_liblist (FILE * file)
>> Elf_Internal_Shdr * section;
>> Elf_Internal_Shdr * string_sec;
>> Elf32_External_Lib * elib;
>> - char * strtab;
>> + char * strtab = NULL;
>> size_t strtab_size;
>> size_t cnt;
>> unsigned i;
>> @@ -11833,6 +11837,7 @@ process_gnu_liblist (FILE * file)
>> break;
>> string_sec = section_headers + section->sh_link;
>>
>> + free (strtab);
>> strtab = (char *) get_data (NULL, file, string_sec->sh_offset, 1,
>> string_sec->sh_size,
>> _("liblist string table"));
>> @@ -11886,6 +11891,7 @@ process_gnu_liblist (FILE * file)
>> }
>> }
>>
>> + free (strtab);
>> return 1;
>> }
>
> Why not simply free strtab at the same time as elib? That version
> is preapproved, if it works.
I have no test for it. Found by static analysis.
next prev parent reply other threads:[~2011-03-14 17:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-08 1:42 Michael Snyder
2011-03-14 12:18 ` Richard Sandiford
2011-03-14 17:56 ` Michael Snyder [this message]
2011-03-14 21:14 ` Michael Snyder
2011-03-30 15:38 ` Nick Clifton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D7E56D3.7070508@vmware.com \
--to=msnyder@vmware.com \
--cc=binutils@sourceware.org \
--cc=richard.sandiford@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).