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

@@ -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;
}