-
Bug
-
Resolution: Fixed
-
P3
-
7
-
b12
-
x86
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8048391 | 8u25 | Alexander Zvegintsev | P3 | Resolved | Fixed | b05 |
JDK-8044441 | 8u20 | Alexander Zvegintsev | P3 | Resolved | Fixed | b20 |
JDK-8053649 | emb-8u26 | Alexander Zvegintsev | P3 | Resolved | Fixed | b17 |
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.
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.
- backported by
-
JDK-8044441 leak in Java_sun_awt_X11_XlibWrapper_getStringBytes?
- Resolved
-
JDK-8048391 leak in Java_sun_awt_X11_XlibWrapper_getStringBytes?
- Resolved
-
JDK-8053649 leak in Java_sun_awt_X11_XlibWrapper_getStringBytes?
- Resolved