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] PR java/29805, Write past end of array in java/typeck.c


Under some circumstances we are writing past the end of an array in java/typeck.c. On some targets (mipsel-linux-gnu) this causes the compiler to ICE when compiling the newarray_overflow.java test from the libjava testsuite.

Bootstrapped and regression tested on i686-pc-linux-gnu (trunk) and mipsel-unknown-linux-gnu (4.2 branch) with no failures.

This gets me to zero FAILs for the libjava testsuite on mipsel-linux-gnu. Yeah!

Since this is a regression from 3.4, OK for both 4.2 and the trunk?

2006-11-11 David Daney <ddaney@avtrex.com>

        PR java/29805
        * typeck.c (build_java_array_type): Increase buffer sizes.
Index: typeck.c
===================================================================
--- typeck.c	(revision 118549)
+++ typeck.c	(working copy)
@@ -356,7 +356,7 @@
 build_java_array_type (tree element_type, HOST_WIDE_INT length)
 {
   tree sig, t, fld, atype, arfld;
-  char buf[12];
+  char buf[23]; /* 20 for the digits of a 64 bit number + "[]" + \0 */
   tree elsig = build_java_signature (element_type);
   tree el_name = element_type;
   buf[0] = '[';
@@ -379,7 +379,7 @@
   if (TREE_CODE (el_name) == TYPE_DECL)
     el_name = DECL_NAME (el_name);
   {
-    char suffix[12];
+    char suffix[23];
     if (length >= 0)
       sprintf (suffix, "[%d]", (int)length); 
     else

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