StringBuffer.java (insert(int,char[])): Avoid NullPointerException so proper check of offset can be done.

* java/lang/StringBuffer.java (insert(int,char[])): Avoid
	NullPointerException so proper check of offset can be done.

From-SVN: r38132
This commit is contained in:
Warren Levy 2000-12-08 13:08:36 +00:00 committed by Warren Levy
parent be17b0fcff
commit d5323b9905
2 changed files with 8 additions and 1 deletions

View file

@ -1,3 +1,8 @@
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.
2000-12-08 Warren Levy <warrenl@redhat.com> 2000-12-08 Warren Levy <warrenl@redhat.com>
* java/io/FileInputStream.java (close): Check if the fd is valid. * java/io/FileInputStream.java (close): Check if the fd is valid.

View file

@ -454,7 +454,9 @@ public final class StringBuffer implements Serializable
*/ */
public StringBuffer insert (int offset, char[] data) 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 /** Insert the <code>char[]</code> argument into this