This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix access beyond array bounds (PR c/23506)


Hi!

DEF_GCC_BUILTIN and DEF_SYNC_BUILTIN pass LIBTYPE BT_LAST to DEF_BUILTIN.
In both cases BOTH_P is false, so def_builtin_1 will never use the libtype
argument passed to it, still it is cleaner not to access builtin_types
beyond its size and pass garbage down to def_builtin_1.
Ok for HEAD?

2005-08-24  Jakub Jelinek  <jakub@redhat.com>

	PR c/23506
	* c-common.c (c_common_nodes_and_builtins): Increase builtin_types
	array by one element, initialize the BT_LAST element with NULL.

--- gcc/c-common.c.jj	2005-08-16 16:23:56.000000000 +0200
+++ gcc/c-common.c	2005-08-24 19:20:10.000000000 +0200
@@ -2951,7 +2951,7 @@ c_common_nodes_and_builtins (void)
 
   typedef enum builtin_type builtin_type;
 
-  tree builtin_types[(int) BT_LAST];
+  tree builtin_types[(int) BT_LAST + 1];
   int wchar_type_size;
   tree array_domain_type;
   tree va_list_ref_type_node;
@@ -3311,6 +3311,7 @@ c_common_nodes_and_builtins (void)
 #undef DEF_FUNCTION_TYPE_VAR_4
 #undef DEF_FUNCTION_TYPE_VAR_5
 #undef DEF_POINTER_TYPE
+  builtin_types[(int) BT_LAST] = NULL_TREE;
 
   c_init_attributes ();
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]