diff options
author | Alan Modra <amodra@gmail.com> | 2002-07-30 05:49:24 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2002-07-30 05:49:24 +0000 |
commit | 487e54f29acc5750992ab2e07574b872a32973ee (patch) | |
tree | dbbc9d8064271f0e56374706f78a69e1e05debd4 /bfd/coffgen.c | |
parent | 9d46020e53ef3b47c3b9fa90d4f93410f233d3d7 (diff) | |
download | gdb-487e54f29acc5750992ab2e07574b872a32973ee.zip gdb-487e54f29acc5750992ab2e07574b872a32973ee.tar.gz gdb-487e54f29acc5750992ab2e07574b872a32973ee.tar.bz2 |
* aoutx.h (some_aout_object_p): Clean up tdata properly on error.
* archive.c (bfd_generic_archive_p): Likewise.
* coff-rs6000.c (_bfd_xcoff_archive_p): Likewise.
(_bfd_xcoff_archive_p): Use bfd_scan_vma in place of strtol.
* coff64-rs6000.c (xcoff64_slurp_armap): Likewise.
(xcoff64_archive_p): Likewise.
(xcoff64_openr_next_archived_file): Likewise.
(xcoff64_archive_p): Clean up tdata properly on error.
* coffgen.c (coff_real_object_p): Likewise.
(coff_object_p): Release filehdr and opthdr.
* ecoff.c (_bfd_ecoff_archive_p): Clean up tdata properly on error.
* ieee.c (ieee_archive_p): Likewise.
* ihex.c (ihex_object_p): Likewise.
(ihex_mkobject): Always allocate tdata.
* peicode.h (pe_ILF_object_p): Release bfd_alloc'd buffer on error.
* srec.c (srec_mkobject): Always allocate tdata.
(srec_object_p): Clean up tdata properly on error.
(symbolsrec_object_p): Likewise.
* versados.c (versados_object_p): Likewise.
* vms-misc.c (_bfd_vms_get_record): Use bfd_malloc instead of malloc,
and bfd_realloc instead of realloc.
(add_new_contents): Use bfd_alloc instead of bfd_malloc for sections.
* vms.c (vms_initialize): Always allocate tdata. Use bfd_alloc in
place of bfd_malloc, simplifying error freeing. Free hash table too.
(vms_object_p): Clean up tdata on error.
(vms_mkobject): Don't complain on stderr if vms_initialize fails.
(vms_close_and_cleanup): Adjust for bfd_alloc use.
Diffstat (limited to 'bfd/coffgen.c')
-rw-r--r-- | bfd/coffgen.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 31788e8..ee6c8fc 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -178,6 +178,7 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) flagword oflags = abfd->flags; bfd_vma ostart = bfd_get_start_address (abfd); PTR tdata; + PTR tdata_save; bfd_size_type readsize; /* length of file_info */ unsigned int scnhsz; char *external_sections; @@ -206,9 +207,10 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) /* Set up the tdata area. ECOFF uses its own routine, and overrides abfd->flags. */ + tdata_save = abfd->tdata.any; tdata = bfd_coff_mkobject_hook (abfd, (PTR) internal_f, (PTR) internal_a); if (tdata == NULL) - return 0; + goto fail2; scnhsz = bfd_coff_scnhsz (abfd); readsize = (bfd_size_type) nscns * scnhsz; @@ -245,6 +247,8 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) fail: bfd_release (abfd, tdata); + fail2: + abfd->tdata.any = tdata_save; abfd->flags = oflags; bfd_get_start_address (abfd) = ostart; return (const bfd_target *) NULL; @@ -270,12 +274,13 @@ coff_object_p (abfd) filehdr = bfd_alloc (abfd, filhsz); if (filehdr == NULL) - return 0; + return NULL; if (bfd_bread (filehdr, filhsz, abfd) != filhsz) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); - return 0; + bfd_release (abfd, filehdr); + return NULL; } bfd_coff_swap_filehdr_in (abfd, filehdr, &internal_f); bfd_release (abfd, filehdr); @@ -292,7 +297,7 @@ coff_object_p (abfd) || internal_f.f_opthdr > aoutsz) { bfd_set_error (bfd_error_wrong_format); - return 0; + return NULL; } nscns = internal_f.f_nscns; @@ -302,13 +307,15 @@ coff_object_p (abfd) opthdr = bfd_alloc (abfd, aoutsz); if (opthdr == NULL) - return 0; + return NULL; if (bfd_bread (opthdr, (bfd_size_type) internal_f.f_opthdr, abfd) != internal_f.f_opthdr) { - return 0; + bfd_release (abfd, opthdr); + return NULL; } bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) &internal_a); + bfd_release (abfd, opthdr); } return coff_real_object_p (abfd, nscns, &internal_f, |