aboutsummaryrefslogtreecommitdiff
path: root/gdb/elfread.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2003-10-31 22:47:48 +0000
committerJim Blandy <jimb@codesourcery.com>2003-10-31 22:47:48 +0000
commite372db49888f31dc07c4ae379b6e7a922ae49e20 (patch)
treec9df754ef5f75a9690826ccf135ce7e5d4ecb7c0 /gdb/elfread.c
parente8bcf01f1b65ef438a40698ce2e2a116d9fc3767 (diff)
downloadgdb-e372db49888f31dc07c4ae379b6e7a922ae49e20.zip
gdb-e372db49888f31dc07c4ae379b6e7a922ae49e20.tar.gz
gdb-e372db49888f31dc07c4ae379b6e7a922ae49e20.tar.bz2
* elfread.c (elf_symtab_read): Allocate correct number of tail
elements to sectinfo structure. (Fix from Woody LaRue.)
Diffstat (limited to 'gdb/elfread.c')
-rw-r--r--gdb/elfread.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 8c27810..9ac30ae 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -398,9 +398,17 @@ elf_symtab_read (struct objfile *objfile, int dynamic)
= max (SECT_OFF_BSS (objfile),
max (SECT_OFF_DATA (objfile),
SECT_OFF_RODATA (objfile)));
+
+ /* max_index is the largest index we'll
+ use into this array, so we must
+ allocate max_index+1 elements for it.
+ However, 'struct stab_section_info'
+ already includes one element, so we
+ need to allocate max_index aadditional
+ elements. */
size = (sizeof (struct stab_section_info)
+ (sizeof (CORE_ADDR)
- * (max_index - 1)));
+ * max_index));
sectinfo = (struct stab_section_info *)
xmmalloc (objfile->md, size);
memset (sectinfo, 0, size);