aboutsummaryrefslogtreecommitdiff
path: root/bfd/ihex.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2002-07-30 05:49:24 +0000
committerAlan Modra <amodra@gmail.com>2002-07-30 05:49:24 +0000
commit487e54f29acc5750992ab2e07574b872a32973ee (patch)
treedbbc9d8064271f0e56374706f78a69e1e05debd4 /bfd/ihex.c
parent9d46020e53ef3b47c3b9fa90d4f93410f233d3d7 (diff)
downloadgdb-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/ihex.c')
-rw-r--r--bfd/ihex.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/bfd/ihex.c b/bfd/ihex.c
index 4cba29b..8188c01 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -193,19 +193,16 @@ static boolean
ihex_mkobject (abfd)
bfd *abfd;
{
- if (abfd->tdata.ihex_data == NULL)
- {
- struct ihex_data_struct *tdata;
- bfd_size_type amt = sizeof (struct ihex_data_struct);
+ struct ihex_data_struct *tdata;
+ bfd_size_type amt = sizeof (struct ihex_data_struct);
- tdata = (struct ihex_data_struct *) bfd_alloc (abfd, amt);
- if (tdata == NULL)
- return false;
- abfd->tdata.ihex_data = tdata;
- tdata->head = NULL;
- tdata->tail = NULL;
- }
+ tdata = (struct ihex_data_struct *) bfd_alloc (abfd, amt);
+ if (tdata == NULL)
+ return false;
+ abfd->tdata.ihex_data = tdata;
+ tdata->head = NULL;
+ tdata->tail = NULL;
return true;
}
@@ -513,6 +510,7 @@ static const bfd_target *
ihex_object_p (abfd)
bfd *abfd;
{
+ PTR tdata_save;
bfd_byte b[9];
unsigned int i;
unsigned int type;
@@ -551,9 +549,14 @@ ihex_object_p (abfd)
}
/* OK, it looks like it really is an Intel Hex file. */
- if (! ihex_mkobject (abfd)
- || ! ihex_scan (abfd))
- return NULL;
+ tdata_save = abfd->tdata.any;
+ if (! ihex_mkobject (abfd) || ! ihex_scan (abfd))
+ {
+ if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
+ bfd_release (abfd, abfd->tdata.any);
+ abfd->tdata.any = tdata_save;
+ return NULL;
+ }
return abfd->xvec;
}