Hey,

This patch just fixes a NPE that was being thrown in the select(int)
method.  

2006-08-01  Tania Bento  <[EMAIL PROTECTED]>

        * java/awt/List.java
        (select): Check if selected is null before execution of
        for-loop.  If it is null, selected is instantiated and
        the index is added to it.

Index: java/awt/List.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/List.java,v
retrieving revision 1.29
diff -u -r1.29 List.java
--- java/awt/List.java	28 Jul 2006 15:18:06 -0000	1.29
+++ java/awt/List.java	1 Aug 2006 15:46:07 -0000
@@ -879,26 +879,32 @@
     ListPeer lp = (ListPeer) getPeer();
     if (lp != null)
       lp.select(index);
-
-    boolean found = false;
-    for (int i = 0; i < selected.length; i++)
-      {
-        if (selected[i] == index)
-          found = true;
-      }
-    if (! found)
-      {
-        if (! isMultipleMode())
-          {
-            selected = new int[] { index };
-            return;
-          }
-        
-        int[] temp = new int[selected.length + 1];
-        System.arraycopy(selected, 0, temp, 0, selected.length);
-        temp[selected.length] = index;
-        selected = temp;
-      }
+    
+   if (selected != null)
+     {
+       boolean found = false;
+       for (int i = 0; i < selected.length; i++)
+         {
+           if (selected[i] == index)
+           found = true;
+         }
+       if (! found)
+         {
+           if (! isMultipleMode())
+             {
+               selected = new int[] { index };
+               return;
+             }       
+           int[] temp = new int[selected.length + 1];
+           System.arraycopy(selected, 0, temp, 0, selected.length);
+           temp[selected.length] = index;
+           selected = temp;
+         }
+     } else 
+       {
+         selected = new int[1];
+         selected[0] = index;
+       }
   }
 
 /*************************************************************************/

Reply via email to