This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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: FYI: minor GridBagLayout fixes


I checked in the attached patch as obvious.  It fixes three Acunia test
cases that were throwing NPEs.

Tom

2003-11-14  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* java/awt/GridBagLayout.java (getLayoutDimensions): Return array of
two
	zero-length int arrays when layoutInfo is null.
	(getLayoutWeights): Return array of two zero-length double arrays when
	layoutInfo is null.

Index: java/awt/GridBagLayout.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/GridBagLayout.java,v
retrieving revision 1.5
diff -u -r1.5 GridBagLayout.java
--- java/awt/GridBagLayout.java	25 Jul 2003 12:50:44 -0000	1.5
+++ java/awt/GridBagLayout.java	14 Nov 2003 22:43:46 -0000
@@ -229,10 +229,15 @@
      */
     public int[][] getLayoutDimensions ()
     {
+	int[][] result = new int [2][];
 	if (layoutInfo == null)
-	    return new int [2][];
+	  {
+	    result[0] = new int[0];
+	    result[1] = new int[0];
+
+	    return result;
+	  }
 
-	int[][] result = new int [2][];
 	result [0] = new int [layoutInfo.cols];
 	System.arraycopy (layoutInfo.colWidths, 0, result [0], 0, layoutInfo.cols);
 	result [1] = new int [layoutInfo.rows];
@@ -242,10 +247,15 @@
 
     public double[][] getLayoutWeights ()
     {
-	if (layoutInfo == null)
-	    return new double [2][];
-      
 	double[][] result = new double [2][];
+	if (layoutInfo == null)
+	  {
+	    result[0] = new double[0];
+	    result[1] = new double[0];
+
+	    return result;
+	  }
+
 	result [0] = new double [layoutInfo.cols];
 	System.arraycopy (layoutInfo.colWeights, 0, result [0], 0, layoutInfo.cols);
 	result [1] = new double [layoutInfo.rows];

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