2007-07-27 Michael Snyder <msnyder@access-company.com>

* coffgen.c (_bfd_coff_read_internal_relocs): Return if count is zero.
This commit is contained in:
Michael Snyder 2007-07-27 18:54:04 +00:00
parent c6aa130f78
commit 9d7038d330
2 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,7 @@
2007-07-27 Michael Snyder <msnyder@access-company.com> 2007-07-27 Michael Snyder <msnyder@access-company.com>
* coffgen.c (_bfd_coff_read_internal_relocs): Return if count is zero.
* elf32-i386.c (elf_i386_check_relocs): Check for null pointer. * elf32-i386.c (elf_i386_check_relocs): Check for null pointer.
2007-07-27 H.J. Lu <hongjiu.lu@intel.com> 2007-07-27 H.J. Lu <hongjiu.lu@intel.com>

View File

@ -409,6 +409,9 @@ _bfd_coff_read_internal_relocs (bfd *abfd,
struct internal_reloc *irel; struct internal_reloc *irel;
bfd_size_type amt; bfd_size_type amt;
if (sec->reloc_count == 0)
return internal_relocs; /* Nothing to do. */
if (coff_section_data (abfd, sec) != NULL if (coff_section_data (abfd, sec) != NULL
&& coff_section_data (abfd, sec)->relocs != NULL) && coff_section_data (abfd, sec)->relocs != NULL)
{ {
@ -425,7 +428,7 @@ _bfd_coff_read_internal_relocs (bfd *abfd,
if (external_relocs == NULL) if (external_relocs == NULL)
{ {
free_external = bfd_malloc (amt); free_external = bfd_malloc (amt);
if (free_external == NULL && sec->reloc_count > 0) if (free_external == NULL)
goto error_return; goto error_return;
external_relocs = free_external; external_relocs = free_external;
} }
@ -439,7 +442,7 @@ _bfd_coff_read_internal_relocs (bfd *abfd,
amt = sec->reloc_count; amt = sec->reloc_count;
amt *= sizeof (struct internal_reloc); amt *= sizeof (struct internal_reloc);
free_internal = bfd_malloc (amt); free_internal = bfd_malloc (amt);
if (free_internal == NULL && sec->reloc_count > 0) if (free_internal == NULL)
goto error_return; goto error_return;
internal_relocs = free_internal; internal_relocs = free_internal;
} }