This is the mail archive of the
java-patches@sources.redhat.com
mailing list for the Java project.
PATCH: java.lang.StringBuffer
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: PATCH: java.lang.StringBuffer
- From: Warren Levy <warrenl at cygnus dot com>
- Date: Fri, 8 Dec 2000 05:07:55 -0800 (PST)
Here's another minor fix from the Mauve testsuite. It gets rid of a
NullPointerException that's thrown in the case that offset is invalid AND
data is null (StringIndexOutOfBoundsException should be thrown).
--warrenl
2000-12-08 Warren Levy <warrenl@redhat.com>
* java/lang/StringBuffer.java (insert(int,char[])): Avoid
NullPointerException so proper check of offset can be done.
Index: java/lang/StringBuffer.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/StringBuffer.java,v
retrieving revision 1.8
diff -u -p -r1.8 StringBuffer.java
--- StringBuffer.java 2000/05/19 17:55:32 1.8
+++ StringBuffer.java 2000/12/08 13:02:18
@@ -454,7 +454,9 @@ public final class StringBuffer implemen
*/
public StringBuffer insert (int offset, char[] data)
{
- return insert (offset, data, 0, data.length);
+ // One could check if offset is invalid here instead of making sure that
+ // data isn't null before dereferencing, but this works just as well.
+ return insert (offset, data, 0, data == null ? 0 : data.length);
}
/** Insert the <code>char[]</code> argument into this