diff --git a/src/solaris/native/java/util/FileSystemPreferences.c b/src/solaris/native/java/util/FileSystemPreferences.c index eb0bf43fec5e0d5dd30c81fdeeeadad76bbfcb94..757f64c34f0de64e4c44f33f474d319e544e7d98 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; }