8034102: Check solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c for JNI pending exceptions
Reviewed-by: chegar, henryjen
This commit is contained in:
parent
87ed9d213a
commit
fa26d0e934
@ -39,12 +39,15 @@ Java_sun_nio_fs_MacOSXNativeDispatcher_normalizepath(JNIEnv* env, jclass this,
|
||||
jint form)
|
||||
{
|
||||
jcharArray result = NULL;
|
||||
char chars_buf[(PATH_MAX + 1) * 2]; // utf16 + zero padding
|
||||
char *chars;
|
||||
CFMutableStringRef csref = CFStringCreateMutable(NULL, 0);
|
||||
if (csref == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, "native heap");
|
||||
} else {
|
||||
char *chars = (char*)(*env)->GetPrimitiveArrayCritical(env, path, 0);
|
||||
return NULL;
|
||||
}
|
||||
chars = (char*)(*env)->GetPrimitiveArrayCritical(env, path, 0);
|
||||
if (chars != NULL) {
|
||||
char chars_buf[(PATH_MAX + 1) * 2]; // utf16 + zero padding
|
||||
jsize len = (*env)->GetArrayLength(env, path);
|
||||
CFStringAppendCharacters(csref, (const UniChar*)chars, len);
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, path, chars, 0);
|
||||
@ -53,24 +56,26 @@ Java_sun_nio_fs_MacOSXNativeDispatcher_normalizepath(JNIEnv* env, jclass this,
|
||||
if (len < PATH_MAX) {
|
||||
if (CFStringGetCString(csref, chars_buf, sizeof(chars_buf), kCFStringEncodingUTF16)) {
|
||||
result = (*env)->NewCharArray(env, len);
|
||||
(*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)&chars_buf);
|
||||
if (result != NULL) {
|
||||
(*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)&chars_buf);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int ulen = (len + 1) * 2;
|
||||
chars = malloc(ulen);
|
||||
if (chars == NULL) {
|
||||
CFRelease(csref);
|
||||
JNU_ThrowOutOfMemoryError(env, "native heap");
|
||||
return result;
|
||||
} else {
|
||||
if (CFStringGetCString(csref, chars, ulen, kCFStringEncodingUTF16)) {
|
||||
result = (*env)->NewCharArray(env, len);
|
||||
(*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)chars);
|
||||
if (result != NULL) {
|
||||
(*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)chars);
|
||||
}
|
||||
}
|
||||
free(chars);
|
||||
}
|
||||
}
|
||||
CFRelease(csref);
|
||||
}
|
||||
CFRelease(csref);
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user