FULL PRODUCT VERSION : java version "1.7.0-ea" Java(TM) SE Runtime Environment (build 1.7.0-ea-b41) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b08, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux lithium 2.6.24-22-generic #1 SMP Mon Nov 24 19:35:06 UTC 2008 x86_64 GNU/Linux A DESCRIPTION OF THE PROBLEM : i just happened to be reading the source and noticed this: JNIEXPORT jbyteArray JNICALL Java_sun_awt_X11_XlibWrapper_getStringBytes (JNIEnv *env, jclass clazz, jlong str_ptr) { unsigned char * str = (unsigned char*) jlong_to_ptr(str_ptr); long length = strlen((char*)str); jbyteArray res = (*env)->NewByteArray(env, length); ! void * storage = malloc(length+1); ! memcpy(storage, str, length+1); (*env)->SetByteArrayRegion(env, res, 0, length, (const signed char*) storage); return res; } i don't understand the reason for the two lines i've marked with a leading !, and think the SetByteArrayRegion call should use 'str' instead of 'storage'. if not, then there's a missing call to free(3). so something's wrong here either way. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : i've not seen this bug in action. REPRODUCIBILITY : This bug can be reproduced always.
|