This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [lto] PATCH: map/unmap LTO sections, + bug fixes
- From: Richard Sandiford <richard at codesourcery dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Sandra Loosemore <sandra at codesourcery dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Kenneth Zadeck <zadeck at naturalbridge dot com>
- Date: Tue, 19 Sep 2006 11:15:06 +0100
- Subject: Re: [lto] PATCH: map/unmap LTO sections, + bug fixes
- References: <4508D01C.60707@codesourcery.com> <4508D1D9.5030405@codesourcery.com>
Mark Mitchell <mark@codesourcery.com> writes:
> Sandra Loosemore wrote:
>> ! const void *
>> ! lto_elf_map_fn_body (lto_file *file,
>> ! const char *fn)
>> {
>> ! /* Look in the ELF file to find the actual data, which should be
>> in the section named LTO_SECTION_NAME_PREFIX || "the function name". */
>> ! const char *name = concat (LTO_SECTION_NAME_PREFIX, fn, NULL);
>> ! Elf_Data *data = lto_elf_find_section_data ((lto_elf_file *)file, name);
>> !
>> ! if (! data)
>> ! return NULL;
>> ! else
>> ! return (const void *)(data->d_buf);
>> }
>
> I think you have a memory leak here: "name" will be allocated with
> malloc, but you never free it. I think you should call free before
> returning, independent of the value returned by lto_elf_find_section_data.
FWIW, another option would be to use ACONCAT.
Richard