+2019-12-30 Alan Modra <amodra@gmail.com>
+
+ * 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.
+
2019-12-30 Alan Modra <amodra@gmail.com>
* coffgen.c (coff_real_object_p): Free malloc'd memory on failure.
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. */
/* 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;
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;
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)