]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* somread.c (som_symtab_read): Avoid using alloca for potentially
authorJoel Brobecker <brobecker@gnat.com>
Wed, 4 Oct 2006 21:36:39 +0000 (21:36 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Wed, 4 Oct 2006 21:36:39 +0000 (21:36 +0000)
        large buffers.

gdb/ChangeLog
gdb/somread.c

index 971a05bd07fccdb240bc2fef384478aa8e4aec9b..c6bf6b3a880f025d7fd6ce240192446403da9c92 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-04  Joel Brobecker  <brobecker@adacore.com>
+
+       * somread.c (som_symtab_read): Avoid using alloca for potentially
+       large buffers.
+
 2006-10-04  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * arch-utils.h (gdbarch_info_fill): Remove duplicate prototype.
index c187d13c1dc5aa2e7b09ce04db01b50e26b4e380..f17094d354f8b2b49bc7d956a36a99f7e29437b3 100644 (file)
@@ -88,15 +88,22 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 
   number_of_symbols = bfd_get_symcount (abfd);
 
-  /* FIXME (alloca): could be quite large. */
-  buf = alloca (symsize * number_of_symbols);
+  /* Allocate a buffer to read in the debug info.
+     We avoid using alloca because the memory size could be so large
+     that we could hit the stack size limit.  */
+  buf = xmalloc (symsize * number_of_symbols);
+  make_cleanup (xfree, buf);
   bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET);
   val = bfd_bread (buf, symsize * number_of_symbols, abfd);
   if (val != symsize * number_of_symbols)
     error (_("Couldn't read symbol dictionary!"));
 
-  /* FIXME (alloca): could be quite large. */
-  stringtab = alloca (obj_som_stringtab_size (abfd));
+  /* Allocate a buffer to read in the som stringtab section of
+     the debugging info.  Again, we avoid using alloca because
+     the data could be so large that we could potentially hit
+     the stack size limitat.  */
+  stringtab = xmalloc (obj_som_stringtab_size (abfd));
+  make_cleanup (xfree, stringtab);
   bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET);
   val = bfd_bread (stringtab, obj_som_stringtab_size (abfd), abfd);
   if (val != obj_som_stringtab_size (abfd))