This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Some FIXME comments about alloca size.
- From: Michael Snyder <msnyder at cygnus dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 7 Jan 2002 18:03:46 -0800
- Subject: [PATCH] Some FIXME comments about alloca size.
No actual changes, just some comments in code where alloca is used
to allocate a buffer of indeterminate (and possibly large) size.
2002-01-07 Michael Snyder <msnyder@redhat.com>
* cp-valprint.c (cp_print_value): FIXME comment, alloca size.
* p-valprint.c (pascal_object_print_value): Ditto.
* somread.c (som_symtab_read): Ditto.
* symfile.c (simple_free_overlay_region_table): Ditto.
* valops.c (value_assign): Ditto.
Index: cp-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-valprint.c,v
retrieving revision 1.10
diff -p -r1.10 cp-valprint.c
*** cp-valprint.c 2001/12/07 22:13:19 1.10
--- cp-valprint.c 2002/01/08 02:05:10
*************** cp_print_value (struct type *type, struc
*** 570,575 ****
--- 570,576 ----
&& ((boffset + offset) < 0
|| (boffset + offset) >= TYPE_LENGTH (type)))
{
+ /* FIXME (alloca): unsafe if baseclass is really really large. */
base_valaddr = (char *) alloca (TYPE_LENGTH (baseclass));
if (target_read_memory (address + offset + boffset, base_valaddr,
TYPE_LENGTH (baseclass)) != 0)
Index: p-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/p-valprint.c,v
retrieving revision 1.8
diff -p -r1.8 p-valprint.c
*** p-valprint.c 2002/01/04 19:16:28 1.8
--- p-valprint.c 2002/01/08 02:05:10
*************** pascal_object_print_value (struct type *
*** 970,975 ****
--- 970,976 ----
if (boffset != -1 && (boffset < 0 || boffset >= TYPE_LENGTH (type)))
{
+ /* FIXME (alloc): not safe is baseclass is really really big. */
base_valaddr = (char *) alloca (TYPE_LENGTH (baseclass));
if (target_read_memory (address + boffset, base_valaddr,
TYPE_LENGTH (baseclass)) != 0)
Index: somread.c
===================================================================
RCS file: /cvs/src/src/gdb/somread.c,v
retrieving revision 1.12
diff -p -r1.12 somread.c
*** somread.c 2001/12/02 22:38:23 1.12
--- somread.c 2002/01/08 02:05:10
*************** som_symtab_read (bfd *abfd, struct objfi
*** 99,110 ****
--- 99,112 ----
number_of_symbols = bfd_get_symcount (abfd);
+ /* FIXME (alloca): could be quite large. */
buf = alloca (symsize * number_of_symbols);
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));
bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET);
val = bfd_bread (stringtab, obj_som_stringtab_size (abfd), abfd);
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.45
diff -p -r1.45 symfile.c
*** symfile.c 2001/12/10 22:04:10 1.45
--- symfile.c 2002/01/08 02:05:11
*************** simple_free_overlay_region_table (void)
*** 3009,3014 ****
--- 3009,3015 ----
static void
read_target_long_array (CORE_ADDR memaddr, unsigned int *myaddr, int len)
{
+ /* FIXME (alloca): Not safe if array is very large. */
char *buf = alloca (len * TARGET_LONG_BYTES);
int i;
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.48
diff -p -r1.48 valops.c
*** valops.c 2002/01/06 22:09:08 1.48
--- valops.c 2002/01/08 02:05:11
*************** value_assign (struct value *toval, struc
*** 697,702 ****
--- 697,703 ----
int amount_copied;
/* Make the buffer large enough in all cases. */
+ /* FIXME (alloca): Not safe for very large data types. */
char *buffer = (char *) alloca (amount_to_copy
+ sizeof (LONGEST)
+ MAX_REGISTER_RAW_SIZE);