Commit a6b5bd3b by Tom Tromey Committed by Tom Tromey

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
parent f18590c6
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,
......
......@@ -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)
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment