[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: FileChannelImpl fixlets
From: |
Mark Wielaard |
Subject: |
FYI: FileChannelImpl fixlets |
Date: |
Sun, 04 Jul 2004 22:54:59 +0200 |
Hi,
The following was reported a long time ago.
It is obviously the correct thing to do.
2004-07-04 Stephen Crawley <address@hidden>
* native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
(Java_gnu_java_nio_channels_FileChannelImpl_read___3BII):
Check zero length early.
(Java_gnu_java_nio_channels_FileChannelImpl_write___3BII):
Check zero length early. Return immediatly when exception is thrown.
We could also have checked the length in the java source, but since I
had this variant of the patch already tested and in my tree I didn't
want to change anything about it just before the release.
Cheers,
Mark
Index: native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
===================================================================
RCS file:
/cvsroot/classpath/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c,v
retrieving revision 1.11
diff -u -r1.11 gnu_java_nio_channels_FileChannelImpl.c
--- native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c 21 Jun 2004
17:15:10 -0000 1.11
+++ native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c 4 Jul 2004
20:54:51 -0000
@@ -539,6 +539,10 @@
native_fd = get_native_fd(env, obj);
+ /* Must return 0 if an attempt is made to read 0 bytes. */
+ if (length == 0)
+ return 0;
+
bufptr = (*env)->GetByteArrayElements(env, buffer, 0);
if (!bufptr)
{
@@ -546,10 +550,6 @@
return(-1);
}
- /* Must return 0 if an attempt is made to read 0 bytes. */
- if (length == 0)
- return 0;
-
bytes_read = 0;
do
{
@@ -621,10 +621,15 @@
native_fd = get_native_fd(env, obj);
+ /* Just return if an attempt is made to write 0 bytes. */
+ if (length == 0)
+ return;
+
bufptr = (*env)->GetByteArrayElements(env, buffer, 0);
if (!bufptr)
{
JCL_ThrowException(env, IO_EXCEPTION, "Unexpected JNI error");
+ return;
}
bytes_written = 0;
@@ -637,6 +642,7 @@
JCL_ThrowException(env, IO_EXCEPTION,
TARGET_NATIVE_LAST_ERROR_STRING());
(*env)->ReleaseByteArrayElements(env, buffer, bufptr, 0);
+ return;
}
bytes_written += n;
}
signature.asc
Description: This is a digitally signed message part
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: FileChannelImpl fixlets,
Mark Wielaard <=