summaryrefslogtreecommitdiff
path: root/bfd/srec.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2002-07-30 05:49:24 +0000
committerAlan Modra <amodra@bigpond.net.au>2002-07-30 05:49:24 +0000
commit5755c32983724a2869a789b3a19ac8513a5338a0 (patch)
tree3d15ba12849a291b7f62e8a455a1d02862a392b2 /bfd/srec.c
parent748fdec091d4d1b7829bf085d61bab7c47acf1f7 (diff)
downloadgdb-5755c32983724a2869a789b3a19ac8513a5338a0.tar.gz
* 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/srec.c')
-rw-r--r--bfd/srec.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/bfd/srec.c b/bfd/srec.c
index 4034e353865..129b2ba4bb5 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -230,22 +230,23 @@ static boolean
srec_mkobject (abfd)
bfd *abfd;
{
+ bfd_size_type amt;
+ tdata_type *tdata;
+
srec_init ();
- if (abfd->tdata.srec_data == NULL)
- {
- bfd_size_type amt = sizeof (tdata_type);
- tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, amt);
- if (tdata == NULL)
- return false;
- abfd->tdata.srec_data = tdata;
- tdata->type = 1;
- tdata->head = NULL;
- tdata->tail = NULL;
- tdata->symbols = NULL;
- tdata->symtail = NULL;
- tdata->csymbols = NULL;
- }
+ amt = sizeof (tdata_type);
+ tdata = (tdata_type *) bfd_alloc (abfd, amt);
+ if (tdata == NULL)
+ return false;
+
+ abfd->tdata.srec_data = tdata;
+ tdata->type = 1;
+ tdata->head = NULL;
+ tdata->tail = NULL;
+ tdata->symbols = NULL;
+ tdata->symtail = NULL;
+ tdata->csymbols = NULL;
return true;
}
@@ -640,6 +641,7 @@ static const bfd_target *
srec_object_p (abfd)
bfd *abfd;
{
+ PTR tdata_save;
bfd_byte b[4];
srec_init ();
@@ -654,9 +656,14 @@ srec_object_p (abfd)
return NULL;
}
- if (! srec_mkobject (abfd)
- || ! srec_scan (abfd))
- return NULL;
+ tdata_save = abfd->tdata.any;
+ if (! srec_mkobject (abfd) || ! srec_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;
+ }
if (abfd->symcount > 0)
abfd->flags |= HAS_SYMS;
@@ -670,6 +677,7 @@ static const bfd_target *
symbolsrec_object_p (abfd)
bfd *abfd;
{
+ PTR tdata_save;
char b[2];
srec_init ();
@@ -684,9 +692,14 @@ symbolsrec_object_p (abfd)
return NULL;
}
- if (! srec_mkobject (abfd)
- || ! srec_scan (abfd))
- return NULL;
+ tdata_save = abfd->tdata.any;
+ if (! srec_mkobject (abfd) || ! srec_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;
+ }
if (abfd->symcount > 0)
abfd->flags |= HAS_SYMS;