-
Bug
-
Resolution: Fixed
-
P3
-
1.1
-
1.1.1
-
sparc
-
solaris_2.5
-
Not verified
Name: saC57035 Date: 12/14/96
The java_io.StreamTokenizer.xxxChars(low,hi) methods work wrong with
hi greater than 255.
They throw unexpected IndexOutOfBoundsException.
Here is the example demonstrating the bug:
---- Test.java ----------------------
import java.io.*;
public class Test {
public static void main( String argv[] ) {
StreamTokenizer st = new StreamTokenizer(new StringBufferInputStream("TEST"));
try {
st.wordChars(20,300);
System.out.println("Test passed");
} catch (Throwable e) {
System.out.println("Test failed: "+e+" is thrown");
}
}
}
-- The output ----------------
Test failed: java.lang.ArrayIndexOutOfBoundsException: 256 is thrown
------------------------------
The bug in source code is evident:
public void wordChars(int low, int hi) {
if (low < 0)
low = 0;
if (hi > ctype.length) // HERE MUST BE ctype.length-1
hi = ctype.length; // AND HERE AS WELL
while (low <= hi)
ctype[low++] |= CT_ALPHA;
}
======================================================================