From 9a566c09260a094d6d8416bd3c8c3783bcd40f5a Mon Sep 17 00:00:00 2001 From: Warren Levy Date: Wed, 7 Apr 1999 19:31:01 +0000 Subject: [PATCH] natString.cc (init(jbyteArray,jint,jint,jstring)): Set count to 0 when InputStreamReader returns -1 for EOF. * java/lang/natString.cc (init(jbyteArray,jint,jint,jstring)): Set count to 0 when InputStreamReader returns -1 for EOF. From-SVN: r26273 --- libjava/ChangeLog | 5 +++++ libjava/java/lang/natString.cc | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index a624e4ebb6a..1d3bb42afcf 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +1999-04-07 Warren Levy + + * java/lang/natString.cc (init(jbyteArray,jint,jint,jstring)): + Set count to 0 when InputStreamReader returns -1 for EOF. + 1999-04-07 Tom Tromey * mauve-libgcj: Omit java.text.Collator, diff --git a/libjava/java/lang/natString.cc b/libjava/java/lang/natString.cc index 5cb7b2c72b4..8aad9ee4b8c 100644 --- a/libjava/java/lang/natString.cc +++ b/libjava/java/lang/natString.cc @@ -392,6 +392,10 @@ java::lang::String::init (jbyteArray bytes, jint offset, jint count, boffset = (char *) elements (array) - (char *) array; // FIXME: this can throw IOException. this->count = ir->read(array, 0, count); + + // In case read() doesn't read anything, change -1 for EOF to a count of 0. + if (this->count < 0) + this->count = 0; } jboolean