This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[patch] BFD ieee.c fix
- To: binutils at sourceware dot cygnus dot com
- Subject: [patch] BFD ieee.c fix
- From: cgd at sibyte dot com (Chris G. Demetriou)
- Date: 17 Oct 2000 16:37:06 -0700
While trolling my source tree for something else I noticed the
following:
bfd/ieee.c:ieee_archive_p() seems quite leaky. I made the following
trivial patch, but there's much more badness here that I don't have
time to go into.
The patch looks trivially correct (or at least "better than what was
there" -- it's hard to describe that function's memory handling as
"correct" 8-), and i've compiled the file, but made no attempt to test
it.
cgd
===================================================================
2000-10-17 Chris Demetriou <cgd@sibyte.com>
* ieee.c (ieee_archive_p): Plug one of many possible
memory leaks in error handling.
Index: ieee.c
===================================================================
RCS file: /cvsroot/systemsw/tools/src/binutils/bfd/ieee.c,v
retrieving revision 1.1.1.2
retrieving revision 1.5
diff -c -r1.1.1.2 -r1.5
*** ieee.c 2000/10/10 00:18:36 1.1.1.2
--- ieee.c 2000/10/17 23:30:10 1.5
***************
*** 1343,1361 ****
ieee->h.abfd = abfd;
if (this_byte (&(ieee->h)) != Module_Beginning)
! {
! abfd->tdata.ieee_ar_data = save;
! goto got_wrong_format_error;
! }
next_byte (&(ieee->h));
library = read_id (&(ieee->h));
if (strcmp (library, "LIBRARY") != 0)
! {
! bfd_release (abfd, ieee);
! abfd->tdata.ieee_ar_data = save;
! goto got_wrong_format_error;
! }
/* Throw away the filename */
read_id (&(ieee->h));
--- 1343,1355 ----
ieee->h.abfd = abfd;
if (this_byte (&(ieee->h)) != Module_Beginning)
! goto got_wrong_format_error;
next_byte (&(ieee->h));
library = read_id (&(ieee->h));
if (strcmp (library, "LIBRARY") != 0)
! goto got_wrong_format_error;
!
/* Throw away the filename */
read_id (&(ieee->h));
***************
*** 1458,1463 ****
--- 1452,1459 ----
return abfd->xvec;
got_wrong_format_error:
+ bfd_release (abfd, ieee);
+ abfd->tdata.ieee_ar_data = save;
bfd_set_error (bfd_error_wrong_format);
error_return:
if (elts != NULL)