aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2006-10-04 21:36:39 +0000
committerJoel Brobecker <brobecker@gnat.com>2006-10-04 21:36:39 +0000
commitf31b3751745fb4e229e571e25ece906194efc52f (patch)
tree374dfc41941d260375e40eb0cc4617572e6aac31 /gdb
parentd0a0254a41e72228a60fe0d3e1044f746d8e56ab (diff)
downloadfsf-binutils-gdb-f31b3751745fb4e229e571e25ece906194efc52f.zip
fsf-binutils-gdb-f31b3751745fb4e229e571e25ece906194efc52f.tar.gz
fsf-binutils-gdb-f31b3751745fb4e229e571e25ece906194efc52f.tar.bz2
* somread.c (som_symtab_read): Avoid using alloca for potentially
large buffers.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/somread.c15
2 files changed, 16 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 971a05b..c6bf6b3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/somread.c b/gdb/somread.c
index c187d13..f17094d 100644
--- a/gdb/somread.c
+++ b/gdb/somread.c
@@ -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))