In VMDirectByteBuffer.c we have two mistakes.
- In get() and put() we call ReleaseByteArrayElements() with the wrong
pointer because we add the offset directly after GetByteArrayElements().
- In put() we copy something into the array after it is released.
Both are fixed with the attached patch.
2006-01-10 Roman Kennke <[EMAIL PROTECTED]>
* native/jni/java-nio/java_nio_VMDirectByteBuffer.c
(get): Release the array with the correct pointer.
(put): Release the array with the correct pointer. Copy the array
around _before_ releasing it.
/Roman
Index: native/jni/java-nio/java_nio_VMDirectByteBuffer.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c,v
retrieving revision 1.11
diff -u -r1.11 java_nio_VMDirectByteBuffer.c
--- native/jni/java-nio/java_nio_VMDirectByteBuffer.c 5 Aug 2005 17:12:52 -0000 1.11
+++ native/jni/java-nio/java_nio_VMDirectByteBuffer.c 10 Jan 2006 14:20:06 -0000
@@ -93,8 +93,8 @@
jobject address, jint index, jbyteArray dst, jint dst_offset, jint dst_len)
{
jbyte *src = (jbyte *) JCL_GetRawData (env, address) + index;
- jbyte *_dst = (*env)->GetByteArrayElements (env, dst, NULL) + dst_offset;
- memcpy (_dst, src, dst_len);
+ jbyte *_dst = (*env)->GetByteArrayElements (env, dst, NULL);
+ memcpy (_dst + dst_offset, src, dst_len);
(*env)->ReleaseByteArrayElements (env, dst, _dst, 0);
}
@@ -103,10 +103,10 @@
(JNIEnv *env, jclass clazz __attribute__ ((__unused__)),
jobject address, jint index, jbyteArray src, jint src_offset, jint src_len)
{
- jbyte *_src = (*env)->GetByteArrayElements (env, src, NULL) + src_offset;
- jbyte *dst = (jbyte *)JCL_GetRawData (env, address) + index;
+ jbyte *_src = (*env)->GetByteArrayElements (env, src, NULL);
+ jbyte *dst = (jbyte *)JCL_GetRawData (env, address);
+ memcpy (dst + index, _src + src_offset, src_len);
(*env)->ReleaseByteArrayElements (env, src, _src, 0);
- memcpy (dst, _src, src_len);
}
JNIEXPORT void JNICALL
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches