natFileDescriptorWin32.cc (read): Handle case where count is 0.

* java/io/natFileDescriptorWin32.cc (read): Handle case where
	count is 0.
	* java/io/natFileDescriptorPosix.cc (read): Handle case where
	count is 0.

From-SVN: r58997
This commit is contained in:
Tom Tromey 2002-11-10 22:23:53 +00:00 committed by Tom Tromey
parent f18590c620
commit a6b5bd3b6b
3 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,10 @@
2002-11-10 Tom Tromey <tromey@redhat.com>
* java/io/natFileDescriptorWin32.cc (read): Handle case where
count is 0.
* java/io/natFileDescriptorPosix.cc (read): Handle case where
count is 0.
* java/io/Externalizable.java, java/io/FilePermission.java,
java/io/ObjectStreamConstants.java, java/io/Serializable.java,
java/io/SerializablePermission.java, java/text/Format.java,

View File

@ -293,6 +293,11 @@ java::io::FileDescriptor::read (jbyteArray buffer, jint offset, jint count)
jsize bsize = JvGetArrayLength (buffer);
if (offset < 0 || count < 0 || offset + count > bsize)
throw new java::lang::ArrayIndexOutOfBoundsException;
// Must return 0 if an attempt is made to read 0 bytes.
if (count == 0)
return 0;
jbyte *bytes = elements (buffer) + offset;
int r = ::read (fd, bytes, count);
if (r == 0)

View File

@ -305,6 +305,10 @@ java::io::FileDescriptor::read(jbyteArray buffer, jint offset, jint count)
if (offset < 0 || count < 0 || offset + count > bsize)
throw new java::lang::ArrayIndexOutOfBoundsException;
// Must return 0 if an attempt is made to read 0 bytes.
if (count == 0)
return 0;
jbyte *bytes = elements (buffer) + offset;
DWORD read;