HDFFV-10246 Add check for string not null before use

This commit is contained in:
Allen Byrne 2017-07-25 15:15:20 -05:00
parent f5317e17a8
commit e790a0b42d
5 changed files with 46 additions and 4 deletions

View File

@ -2398,6 +2398,7 @@
./tools/test/h5diff/testfiles/h5diff_udfail.txt
./tools/test/h5diff/testfiles/diff_strings1.h5
./tools/test/h5diff/testfiles/diff_strings2.h5
./tools/test/h5diff/testfiles/h5diff_vlstr.txt
#vds
./tools/test/h5diff/testfiles/h5diff_v1.txt
./tools/test/h5diff/testfiles/h5diff_v2.txt

View File

@ -673,21 +673,33 @@ static hsize_t diff_datum(void *_mem1,
h5difftrace("diff_datum H5T_STRING variable\n");
/* Get pointer to first string */
s1 = *(char**) mem1;
size1 = HDstrlen(s1);
if(s1)
size1 = HDstrlen(s1);
else
size1 = 0;
/* Get pointer to second string */
s2 = *(char**) mem2;
size2 = HDstrlen(s2);
if(s2)
size2 = HDstrlen(s2);
else
size2 = 0;
}
else if (H5T_STR_NULLTERM == pad) {
h5difftrace("diff_datum H5T_STRING null term\n");
/* Get pointer to first string */
s1 = (char*) mem1;
size1 = HDstrlen(s1);
if(s1)
size1 = HDstrlen(s1);
else
size1 = 0;
if (size1 > size_mtype)
size1 = size_mtype;
/* Get pointer to second string */
s2 = (char*) mem2;
size2 = HDstrlen(s2);
if(s2)
size2 = HDstrlen(s2);
else
size2 = 0;
if (size2 > size_mtype)
size2 = size_mtype;
}

View File

@ -95,6 +95,8 @@
${HDF5_TOOLS_DIR}/testfiles/vds/5_b.h5
${HDF5_TOOLS_DIR}/testfiles/vds/5_c.h5
${HDF5_TOOLS_DIR}/testfiles/vds/5_vds.h5
# tools/testfiles
${HDF5_TOOLS_DIR}/testfiles/tvlstr.h5
)
set (LIST_OTHER_TEST_FILES
@ -286,6 +288,7 @@
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v1.txt
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v2.txt
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v3.txt
${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_vlstr.txt
)
set (LIST_WIN_TEST_FILES
@ -311,6 +314,8 @@
HDFTEST_COPY_FILE("${h5_tstfiles}" "${PROJECT_BINARY_DIR}/PAR/testfiles/${fname}" "h5diff_files")
endif ()
endforeach ()
# copy second version of tvlstr.h5
HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tvlstr.h5" "${PROJECT_BINARY_DIR}/testfiles/tvlstr2.h5" "h5diff_files")
#
@ -888,6 +893,8 @@
h5diff_v2.out.err
h5diff_v3.out
h5diff_v3.out.err
h5diff_vlstr.out
h5diff_vlstr.out.err
)
set_tests_properties (H5DIFF-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
if (NOT "${last_test}" STREQUAL "")
@ -1465,6 +1472,7 @@ ADD_H5_TEST (h5diff_487 1 -v --exclude-path "/group1/dset" h5diff_exclude3-1.h5
# # diff various multiple vlen and fixed strings in a compound type dataset
# ##############################################################################
ADD_H5_TEST (h5diff_530 0 -v ${COMP_VL_STRS_FILE} ${COMP_VL_STRS_FILE} /group /group_copy)
ADD_H5_TEST (h5diff_vlstr 0 -v tvlstr.h5 tvlstr2.h5)
# ##############################################################################
# # Test container types (array,vlen) with multiple nested compound types

View File

@ -0,0 +1,16 @@
file1 file2
---------------------------------------
x x /
x x /Dataset1
x x /vl_string_type
group : </> and </>
0 differences found
attribute: <test_scalar of </>> and <test_scalar of </>>
0 differences found
dataset: </Dataset1> and </Dataset1>
0 differences found
datatype: </vl_string_type> and </vl_string_type>
0 differences found
EXIT CODE: 0

View File

@ -124,6 +124,7 @@ $SRC_H5DIFF_TESTFILES/tmpSingleSiteBethe.reference.h5
$SRC_H5DIFF_TESTFILES/tmpSingleSiteBethe.output.h5
$SRC_H5DIFF_TESTFILES/diff_strings1.h5
$SRC_H5DIFF_TESTFILES/diff_strings2.h5
$SRC_TOOLS_TESTFILES/tvlstr.h5
"
LIST_HDF5_VDS_TEST_FILES="
@ -341,6 +342,7 @@ $SRC_H5DIFF_TESTFILES/h5diff_tmp2.txt
$SRC_H5DIFF_TESTFILES/h5diff_v1.txt
$SRC_H5DIFF_TESTFILES/h5diff_v2.txt
$SRC_H5DIFF_TESTFILES/h5diff_v3.txt
$SRC_H5DIFF_TESTFILES/h5diff_vlstr.txt
"
#
@ -566,6 +568,8 @@ SKIP() {
##############################################################################
# prepare for test
COPY_TESTFILES_TO_TESTDIR
# second copy of tvlstr.h5
$CP -f $SRC_TOOLS_TESTFILES/tvlstr.h5 $TESTDIR/tvlstr.h5
# ############################################################################
# # Common usage
@ -1141,6 +1145,7 @@ TOOLTEST h5diff_487.txt -v --exclude-path "/group1/dset" h5diff_exclude3-1.h5 h5
# # diff various multiple vlen and fixed strings in a compound type dataset
# ##############################################################################
TOOLTEST h5diff_530.txt -v h5diff_comp_vl_strs.h5 h5diff_comp_vl_strs.h5 /group /group_copy
TOOLTEST h5diff_vlstr.txt -v tvlstr.h5 tvlstr2.h5
# ##############################################################################
# # Test container types (array,vlen) with multiple nested compound types