* elfread.c (elf_symtab_read): Allocate correct number of tail
authorJim Blandy <jimb@codesourcery.com>
Fri, 31 Oct 2003 22:47:48 +0000 (22:47 +0000)
committerJim Blandy <jimb@codesourcery.com>
Fri, 31 Oct 2003 22:47:48 +0000 (22:47 +0000)
elements to sectinfo structure.  (Fix from Woody LaRue.)

gdb/ChangeLog
gdb/elfread.c

index c97c0dd50ae18e590521db92f36a3a22ebff3c10..a53260ab0b3d60f859f596c4282590cde2979d5b 100644 (file)
@@ -1,3 +1,8 @@
+2003-10-31  Jim Blandy  <jimb@redhat.com>
+
+       * elfread.c (elf_symtab_read): Allocate correct number of tail
+       elements to sectinfo structure.  (Fix from Woody LaRue.)
+
 2003-10-31  Andrew Cagney  <cagney@redhat.com>
 
        * stack.c (return_command): Use get_frame_type, instead of
index 8c278107d377eba5729f23fbfbe428119a9e55bc..9ac30aeeb9f3f8d71cca3f2aa59208629a258fc2 100644 (file)
@@ -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);