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:
parent
f18590c620
commit
a6b5bd3b6b
3 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue