* [PATCH] memory leak in coffgen
@ 2007-07-25 23:53 msnyder
2007-07-26 12:54 ` Alan Modra
0 siblings, 1 reply; 6+ messages in thread
From: msnyder @ 2007-07-25 23:53 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 137 bytes --]
This one's mine (not Coverity's). I noticed that this malloc buffer
was not getting freed even when it was not requested to be cached.
[-- Attachment #2: coffgen2.txt --]
[-- Type: text/plain, Size: 1527 bytes --]
2007-07-25 Michael Snyder <msnyder@svkmacdonelllnx>
* coffgen.c (_bfd_coff_read_internal_relocs): If internal_relocs
are not to be cached, free the temporary buffer.
Index: coffgen.c
===================================================================
RCS file: /cvs/src/src/bfd/coffgen.c,v
retrieving revision 1.59
diff -p -r1.59 coffgen.c
*** coffgen.c 12 Jul 2007 07:16:40 -0000 1.59
--- coffgen.c 25 Jul 2007 23:41:50 -0000
*************** _bfd_coff_read_internal_relocs (bfd *abf
*** 457,473 ****
free_external = NULL;
}
! if (cache && free_internal != NULL)
{
! if (coff_section_data (abfd, sec) == NULL)
{
! amt = sizeof (struct coff_section_tdata);
! sec->used_by_bfd = bfd_zalloc (abfd, amt);
! if (sec->used_by_bfd == NULL)
! goto error_return;
! coff_section_data (abfd, sec)->contents = NULL;
}
- coff_section_data (abfd, sec)->relocs = free_internal;
}
return internal_relocs;
--- 457,478 ----
free_external = NULL;
}
! if (free_internal != NULL)
{
! if (cache == FALSE)
! free (free_internal);
! else
{
! if (coff_section_data (abfd, sec) == NULL)
! {
! amt = sizeof (struct coff_section_tdata);
! sec->used_by_bfd = bfd_zalloc (abfd, amt);
! if (sec->used_by_bfd == NULL)
! goto error_return;
! coff_section_data (abfd, sec)->contents = NULL;
! }
! coff_section_data (abfd, sec)->relocs = free_internal;
}
}
return internal_relocs;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memory leak in coffgen
2007-07-25 23:53 [PATCH] memory leak in coffgen msnyder
@ 2007-07-26 12:54 ` Alan Modra
2007-07-26 18:45 ` msnyder
2007-07-31 0:39 ` msnyder
0 siblings, 2 replies; 6+ messages in thread
From: Alan Modra @ 2007-07-26 12:54 UTC (permalink / raw)
To: msnyder; +Cc: binutils
On Wed, Jul 25, 2007 at 04:45:10PM -0700, msnyder@sonic.net wrote:
> * coffgen.c (_bfd_coff_read_internal_relocs): If internal_relocs
> are not to be cached, free the temporary buffer.
OK.
> ! if (cache == FALSE)
if (!cache)
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memory leak in coffgen
2007-07-26 12:54 ` Alan Modra
@ 2007-07-26 18:45 ` msnyder
2007-07-31 0:39 ` msnyder
1 sibling, 0 replies; 6+ messages in thread
From: msnyder @ 2007-07-26 18:45 UTC (permalink / raw)
To: binutils
> On Wed, Jul 25, 2007 at 04:45:10PM -0700, msnyder@sonic.net wrote:
>> * coffgen.c (_bfd_coff_read_internal_relocs): If internal_relocs
>> are not to be cached, free the temporary buffer.
>
> OK.
>
>> ! if (cache == FALSE)
>
> if (!cache)
Committed, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memory leak in coffgen
2007-07-26 12:54 ` Alan Modra
2007-07-26 18:45 ` msnyder
@ 2007-07-31 0:39 ` msnyder
2007-07-31 7:47 ` Alan Modra
1 sibling, 1 reply; 6+ messages in thread
From: msnyder @ 2007-07-31 0:39 UTC (permalink / raw)
To: msnyder, binutils
> On Wed, Jul 25, 2007 at 04:45:10PM -0700, msnyder@sonic.net wrote:
>> * coffgen.c (_bfd_coff_read_internal_relocs): If internal_relocs
>> are not to be cached, free the temporary buffer.
>
> OK.
Alan, unfortunately, I think I was wrong about this one.
We can't free "free_internal" at this point, because its aliased
by internal_relocs, and we're going to return that.
OK to back out this change?
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memory leak in coffgen
2007-07-31 0:39 ` msnyder
@ 2007-07-31 7:47 ` Alan Modra
2007-07-31 11:37 ` msnyder
0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2007-07-31 7:47 UTC (permalink / raw)
To: msnyder; +Cc: binutils
On Mon, Jul 30, 2007 at 11:36:52AM -0700, msnyder@sonic.net wrote:
> > On Wed, Jul 25, 2007 at 04:45:10PM -0700, msnyder@sonic.net wrote:
> >> * coffgen.c (_bfd_coff_read_internal_relocs): If internal_relocs
> >> are not to be cached, free the temporary buffer.
> >
> > OK.
>
> Alan, unfortunately, I think I was wrong about this one.
>
> We can't free "free_internal" at this point, because its aliased
> by internal_relocs, and we're going to return that.
>
> OK to back out this change?
Yes of course.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memory leak in coffgen
2007-07-31 7:47 ` Alan Modra
@ 2007-07-31 11:37 ` msnyder
0 siblings, 0 replies; 6+ messages in thread
From: msnyder @ 2007-07-31 11:37 UTC (permalink / raw)
To: msnyder, binutils
> On Mon, Jul 30, 2007 at 11:36:52AM -0700, msnyder@sonic.net wrote:
>> > On Wed, Jul 25, 2007 at 04:45:10PM -0700, msnyder@sonic.net wrote:
>> >> * coffgen.c (_bfd_coff_read_internal_relocs): If internal_relocs
>> >> are not to be cached, free the temporary buffer.
>> >
>> > OK.
>>
>> Alan, unfortunately, I think I was wrong about this one.
>>
>> We can't free "free_internal" at this point, because its aliased
>> by internal_relocs, and we're going to return that.
>>
>> OK to back out this change?
>
> Yes of course.
Thanks, change reverted.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-07-31 3:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-25 23:53 [PATCH] memory leak in coffgen msnyder
2007-07-26 12:54 ` Alan Modra
2007-07-26 18:45 ` msnyder
2007-07-31 0:39 ` msnyder
2007-07-31 7:47 ` Alan Modra
2007-07-31 11:37 ` msnyder
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).