diff options
author | Jordan Henderson <jhenderson@hdfgroup.org> | 2019-02-12 17:41:55 (GMT) |
---|---|---|
committer | Jordan Henderson <jhenderson@hdfgroup.org> | 2019-02-12 17:56:42 (GMT) |
commit | 3acd486b83f319579b1c6884c90289b0eb1d44a6 (patch) | |
tree | f4b0093c1915d2fbd704ea1948b80ba089ab82f5 /java/src/jni/h5pFAPLImp.c | |
parent | 8f42566f7ac087504c115c7d98b79c56604c2ebe (diff) | |
download | hdf5-3acd486b83f319579b1c6884c90289b0eb1d44a6.zip hdf5-3acd486b83f319579b1c6884c90289b0eb1d44a6.tar.gz hdf5-3acd486b83f319579b1c6884c90289b0eb1d44a6.tar.bz2 |
Fixes for JNI updates
Diffstat (limited to 'java/src/jni/h5pFAPLImp.c')
-rw-r--r-- | java/src/jni/h5pFAPLImp.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/java/src/jni/h5pFAPLImp.c b/java/src/jni/h5pFAPLImp.c index aec6581..acfc853 100644 --- a/java/src/jni/h5pFAPLImp.c +++ b/java/src/jni/h5pFAPLImp.c @@ -384,6 +384,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log UNUSED(clss); + if (NULL == logfile) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_fapl_log: log file name is NULL"); + PIN_JAVA_STRING(ENVONLY, logfile, pLogfile, NULL, "H5Pset_fapl_log: log file name not pinned"); if ((retVal = H5Pset_fapl_log((hid_t)fapl_id, pLogfile, (unsigned long long)flags, (size_t)buf_size)) < 0) @@ -421,10 +424,12 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr, jboolean relax) { const char * const *mName = NULL; + const char *utf8 = NULL; jboolean isCopy; jboolean bb; jobject o; jstring rstring; + jstring obj; jclass Sjc; size_t i; jlong *thefaplArray = NULL; @@ -445,11 +450,8 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi PIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, &isCopy, "H5Pset_fapl_multi: memb_addr not pinned"); if (memb_name) { - jstring obj; - for (i = 0; i < H5FD_MEM_NTYPES; i++) { - const char *utf8 = NULL; - size_t str_len; + size_t str_len; if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray) memb_name, (jsize) i))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -474,6 +476,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_fapl_multi: memory allocation failed"); HDstrncpy(member_name[i], utf8, str_len + 1); + (member_name[i])[str_len] = '\0'; UNPIN_JAVA_STRING(ENVONLY, obj, utf8); utf8 = NULL; @@ -493,6 +496,8 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); for (i = 0; i < H5FD_MEM_NTYPES; i++) { + if (!member_name[i]) continue; + if (NULL == (rstring = ENVPTR->NewStringUTF(ENVONLY, member_name[i]))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_fapl_multi: out of memory - unable to construct string from UTF characters"); @@ -522,7 +527,12 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi } done: - h5str_array_free(member_name, H5FD_MEM_NTYPES); + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + if (member_name[i]) + HDfree(member_name[i]); + } + if (utf8) + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); if (theaddrArray) UNPIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, (status < 0) ? JNI_ABORT : 0); if (thefaplArray) @@ -621,6 +631,11 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split UNUSED(clss); + if (NULL == metaext) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_fapl_split: metaext is NULL"); + if (NULL == rawext) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_fapl_split: rawext is NULL"); + PIN_JAVA_STRING(ENVONLY, metaext, mstr, NULL, "H5Pset_fapl_split: metaext not pinned"); PIN_JAVA_STRING(ENVONLY, rawext, rstr, NULL, "H5Pset_fapl_split: rawext not pinned"); @@ -1125,12 +1140,17 @@ Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config if (NULL == (j_str = (jstring)ENVPTR->GetObjectField(ENVONLY, cache_config, fid))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - PIN_JAVA_STRING(ENVONLY, j_str, str, NULL, "H5Pset_mdc_config: cache_config not pinned"); + if (j_str) { + PIN_JAVA_STRING(ENVONLY, j_str, str, NULL, "H5Pset_mdc_config: cache_config not pinned"); - HDstrncpy(cacheinfo.trace_file_name, str, H5AC__MAX_TRACE_FILE_NAME_LEN + 1); + HDstrncpy(cacheinfo.trace_file_name, str, H5AC__MAX_TRACE_FILE_NAME_LEN + 1); + cacheinfo.trace_file_name[H5AC__MAX_TRACE_FILE_NAME_LEN] = '\0'; - UNPIN_JAVA_STRING(ENVONLY, j_str, str); - str = NULL; + UNPIN_JAVA_STRING(ENVONLY, j_str, str); + str = NULL; + } + else + HDmemset(cacheinfo.trace_file_name, 0, H5AC__MAX_TRACE_FILE_NAME_LEN + 1); if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "evictions_enabled", "Z"))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -1383,6 +1403,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options UNUSED(clss); + if (NULL == location) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_mdc_log_options: location string is NULL"); + PIN_JAVA_STRING(ENVONLY, location, locStr, NULL, "H5Pset_mdc_log_options: location string not pinned"); if ((retVal = H5Pset_mdc_log_options((hid_t)fapl_id, (hbool_t)is_enabled, locStr, (hbool_t)start_on_access)) < 0) |