From 95eea3ea4fdee0ab0b6da92cc21fc76e16e0e695 Mon Sep 17 00:00:00 2001 From: dxu Date: Wed, 8 Jan 2014 13:25:10 -0800 Subject: [PATCH] 8028726: (prefs) Check src/solaris/native/java/util/FileSystemPreferences.c for JNI pending exceptions Reviewed-by: lancea, chegar, alanb --- .../native/java/util/FileSystemPreferences.c | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/solaris/native/java/util/FileSystemPreferences.c b/src/solaris/native/java/util/FileSystemPreferences.c index eb0bf43fe..757f64c34 100644 --- a/src/solaris/native/java/util/FileSystemPreferences.c +++ b/src/solaris/native/java/util/FileSystemPreferences.c @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -38,12 +38,14 @@ JNIEXPORT jint JNICALL Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env, jclass thisclass, jstring java_fname, jint permission) { - const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); - int result; - result = chmod(fname, permission); - if (result != 0) - result = errno; - JNU_ReleaseStringPlatformChars(env, java_fname, fname); + const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL); + int result = -1; + if (fname) { + result = chmod(fname, permission); + if (result != 0) + result = errno; + JNU_ReleaseStringPlatformChars(env, java_fname, fname); + } return (jint) result; } @@ -61,13 +63,16 @@ typedef struct flock64 FLOCK; JNIEXPORT jintArray JNICALL Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, 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 result[2]; - jintArray javaResult; + jintArray javaResult = NULL; int old_umask; FLOCK fl; + if (!fname) + return javaResult; + fl.l_whence = SEEK_SET; fl.l_len = 0; fl.l_start = 0; @@ -104,7 +109,8 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, } JNU_ReleaseStringPlatformChars(env, java_fname, fname); javaResult = (*env)->NewIntArray(env,2); - (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result); + if (javaResult) + (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result); return javaResult; } -- GitLab