diff options
author | Alan Modra <amodra@gmail.com> | 2019-12-30 21:40:08 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-12-30 23:50:35 +1030 |
commit | a7ac9aa525de25d3bc6e7bfd37615092a4f94055 (patch) | |
tree | e18c0c5526ebd4e581f1af797b7897cd124d6b5c /bfd/vms-alpha.c | |
parent | 37d5ab199b072e3cf1e8bf2a9262767c4737d256 (diff) | |
download | gdb-a7ac9aa525de25d3bc6e7bfd37615092a4f94055.zip gdb-a7ac9aa525de25d3bc6e7bfd37615092a4f94055.tar.gz gdb-a7ac9aa525de25d3bc6e7bfd37615092a4f94055.tar.bz2 |
vms-alpha.c object_p memory leaks
* vms-alpha.c (alpha_vms_free_private): New function, extracted..
(vms_close_and_cleanup): ..from here.
(alpha_vms_object_p): Call alpha_vms_free_private on failure.
Diffstat (limited to 'bfd/vms-alpha.c')
-rw-r--r-- | bfd/vms-alpha.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 6a08761..e4928d7 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -2634,6 +2634,22 @@ vms_initialize (bfd * abfd) return FALSE; } +/* Free malloc'd memory. */ + +static void +alpha_vms_free_private (bfd *abfd) +{ + struct module *module; + + free (PRIV (recrd.buf)); + free (PRIV (sections)); + free (PRIV (syms)); + free (PRIV (dst_ptr_offsets)); + + for (module = PRIV (modules); module; module = module->next) + free (module->file_table); +} + /* Check the format for a file being read. Return a (bfd_target *) if it's an object file or zero if not. */ @@ -2648,7 +2664,10 @@ alpha_vms_object_p (bfd *abfd) /* Allocate alpha-vms specific data. */ if (!vms_initialize (abfd)) - goto error_ret; + { + abfd->tdata.any = tdata_save; + return NULL; + } if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET)) goto err_wrong_format; @@ -2788,8 +2807,7 @@ alpha_vms_object_p (bfd *abfd) bfd_set_error (bfd_error_wrong_format); error_ret: - if (PRIV (recrd.buf)) - free (PRIV (recrd.buf)); + alpha_vms_free_private (abfd); if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL) bfd_release (abfd, abfd->tdata.any); abfd->tdata.any = tdata_save; @@ -9339,15 +9357,7 @@ vms_close_and_cleanup (bfd * abfd) if (abfd->format == bfd_object) { - struct module *module; - - free (PRIV (recrd.buf)); - free (PRIV (sections)); - free (PRIV (syms)); - free (PRIV (dst_ptr_offsets)); - - for (module = PRIV (modules); module; module = module->next) - free (module->file_table); + alpha_vms_free_private (abfd); #ifdef VMS if (abfd->direction == write_direction) |