提交 95eea3ea 编写于 作者: D dxu

8028726: (prefs) Check src/solaris/native/java/util/FileSystemPreferences.c...

8028726: (prefs) Check src/solaris/native/java/util/FileSystemPreferences.c for JNI pending exceptions
Reviewed-by: lancea, chegar, alanb
上级 858cd0f3
/* /*
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -38,12 +38,14 @@ ...@@ -38,12 +38,14 @@
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env, Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env,
jclass thisclass, jstring java_fname, jint permission) { jclass thisclass, jstring java_fname, jint permission) {
const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL);
int result; int result = -1;
result = chmod(fname, permission); if (fname) {
if (result != 0) result = chmod(fname, permission);
result = errno; if (result != 0)
JNU_ReleaseStringPlatformChars(env, java_fname, fname); result = errno;
JNU_ReleaseStringPlatformChars(env, java_fname, fname);
}
return (jint) result; return (jint) result;
} }
...@@ -61,13 +63,16 @@ typedef struct flock64 FLOCK; ...@@ -61,13 +63,16 @@ typedef struct flock64 FLOCK;
JNIEXPORT jintArray JNICALL JNIEXPORT jintArray JNICALL
Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env,
jclass thisclass, jstring java_fname, jint permission, jboolean shared) { jclass thisclass, jstring java_fname, jint permission, jboolean shared) {
const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL);
int fd, rc; int fd, rc;
int result[2]; int result[2];
jintArray javaResult; jintArray javaResult = NULL;
int old_umask; int old_umask;
FLOCK fl; FLOCK fl;
if (!fname)
return javaResult;
fl.l_whence = SEEK_SET; fl.l_whence = SEEK_SET;
fl.l_len = 0; fl.l_len = 0;
fl.l_start = 0; fl.l_start = 0;
...@@ -104,7 +109,8 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, ...@@ -104,7 +109,8 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env,
} }
JNU_ReleaseStringPlatformChars(env, java_fname, fname); JNU_ReleaseStringPlatformChars(env, java_fname, fname);
javaResult = (*env)->NewIntArray(env,2); javaResult = (*env)->NewIntArray(env,2);
(*env)->SetIntArrayRegion(env, javaResult, 0, 2, result); if (javaResult)
(*env)->SetIntArrayRegion(env, javaResult, 0, 2, result);
return javaResult; return javaResult;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册