aboutsummaryrefslogtreecommitdiff
path: root/bfd/coffgen.c
diff options
context:
space:
mode:
authorAlexander Cherepanov <cherepan@mccme.ru>2014-11-21 11:19:49 +0000
committerNick Clifton <nickc@redhat.com>2014-11-21 11:19:49 +0000
commitcd11f78f810cf12b04046ac954ceb6528b00956c (patch)
treeb60fbc2d08d7eaca583b67b66ca7f8e421ac485d /bfd/coffgen.c
parent3cfdb7812cda6ca610be8bf65ffaf5138dc0d379 (diff)
downloadfsf-binutils-gdb-cd11f78f810cf12b04046ac954ceb6528b00956c.zip
fsf-binutils-gdb-cd11f78f810cf12b04046ac954ceb6528b00956c.tar.gz
fsf-binutils-gdb-cd11f78f810cf12b04046ac954ceb6528b00956c.tar.bz2
Fix a snafu setting up the string table read in from a COFF file.
PR binutils/17512 * coffgen.c (_bfd_coff_read_string_table): Test allocation of string table before clearing the first few bytes.
Diffstat (limited to 'bfd/coffgen.c')
-rw-r--r--bfd/coffgen.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index a22f67a..f19efc3 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -1711,15 +1711,15 @@ _bfd_coff_read_string_table (bfd *abfd)
}
strings = (char *) bfd_malloc (strsize + 1);
+ if (strings == NULL)
+ return NULL;
+
/* PR 17521 file: 079-54929-0.004.
A corrupt file could contain an index that points into the first
STRING_SIZE_SIZE bytes of the string table, so make sure that
they are zero. */
memset (strings, 0, STRING_SIZE_SIZE);
- if (strings == NULL)
- return NULL;
-
if (bfd_bread (strings + STRING_SIZE_SIZE, strsize - STRING_SIZE_SIZE, abfd)
!= strsize - STRING_SIZE_SIZE)
{