if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
list_matching_formats (matching);
free (matching);
+ bfd_close (abfd);
return NULL;
}
if (bfd_get_flavour (abfd) != bfd_target_coff_flavour
|| !obj_pe (abfd))
{
non_fatal (_("%s: not a PE file"), filename);
+ bfd_close (abfd);
return NULL;
}
if (sec == NULL)
{
non_fatal (_("%s: no resource section"), filename);
+ bfd_close (abfd);
return NULL;
}
if (size > (bfd_size_type) get_file_size (filename))
{
non_fatal (_("%s: .rsrc section is bigger than the file!"), filename);
+ bfd_close (abfd);
return NULL;
}
if (! bfd_set_format (abfd, bfd_object))
{
bfd_nonfatal ("bfd_set_format");
+ bfd_close_all_done (abfd);
return false;
}
if (! bfd_set_arch_mach (abfd, bfd_arch_sh, 0))
{
bfd_nonfatal ("bfd_set_arch_mach(sh)");
+ bfd_close_all_done (abfd);
return false;
}
#elif defined DLLTOOL_MIPS
if (! bfd_set_arch_mach (abfd, bfd_arch_mips, 0))
{
bfd_nonfatal ("bfd_set_arch_mach(mips)");
+ bfd_close_all_done (abfd);
return false;
}
#elif defined DLLTOOL_ARM
if (! bfd_set_arch_mach (abfd, bfd_arch_arm, 0))
{
bfd_nonfatal ("bfd_set_arch_mach(arm)");
+ bfd_close_all_done (abfd);
return false;
}
#elif defined DLLTOOL_AARCH64
if (! bfd_set_arch_mach (abfd, bfd_arch_aarch64, 0))
{
bfd_nonfatal ("bfd_set_arch_mach(aarch64)");
+ bfd_close_all_done (abfd);
return false;
}
#else
if (! bfd_set_arch_mach (abfd, bfd_arch_i386, 0))
{
bfd_nonfatal ("bfd_set_arch_mach(i386)");
+ bfd_close_all_done (abfd);
return false;
}
#endif
if (! bfd_set_file_flags (abfd, HAS_SYMS | HAS_RELOC))
{
bfd_nonfatal ("bfd_set_file_flags");
+ bfd_close_all_done (abfd);
return false;
}
if (sec == NULL)
{
bfd_nonfatal ("bfd_make_section");
+ bfd_close_all_done (abfd);
return false;
}
if (! bfd_set_symtab (abfd, &sec->symbol, 1))
{
bfd_nonfatal ("bfd_set_symtab");
+ bfd_close_all_done (abfd);
return false;
}
/* Actually convert the resources to binary. */
if (!coff_to_bin (resources, &cwi))
- return false;
+ {
+ bfd_close_all_done (abfd);
+ free (cwi.relocs);
+ return false;
+ }
/* Add another few bytes to the directory strings if needed for
alignment. */
if (!bfd_set_section_size (sec, length))
{
bfd_nonfatal ("bfd_set_section_size");
+ bfd_close_all_done (abfd);
+ free (cwi.relocs);
return false;
}
if (! bfd_set_section_contents (abfd, sec, d->data, offset, d->length))
{
bfd_nonfatal ("bfd_set_section_contents");
+ bfd_close_all_done (abfd);
+ free (cwi.relocs);
return false;
}
offset += d->length;
{
if (res_to_bin (cwi.wrbfd, (rc_uint_type) offset, rd->res)
== (rc_uint_type) -1)
- return false;
+ {
+ bfd_close_all_done (abfd);
+ free (cwi.relocs);
+ return false;
+ }
offset += rd->length;
}
if (! bfd_close (abfd))
{
bfd_nonfatal ("bfd_close");
+ free (cwi.relocs);
return false;
}