diff options
author | Sean McBride <sean@rogue-research.com> | 2021-05-03 15:22:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-03 15:22:53 (GMT) |
commit | 3899e090dfd2e88b4a1929e304df835fd7a3d316 (patch) | |
tree | 449a2f35e1efe2d8e19adcefd76d85c0830197fc /c++ | |
parent | 44db310d8d45d7d639b5b7745636d1a58555d89a (diff) | |
download | hdf5-3899e090dfd2e88b4a1929e304df835fd7a3d316.zip hdf5-3899e090dfd2e88b4a1929e304df835fd7a3d316.tar.gz hdf5-3899e090dfd2e88b4a1929e304df835fd7a3d316.tar.bz2 |
Ubsan fixes (#498)
* Fixed use of null pointer identified by UBSan
UBSan warned:
runtime error: member access within null pointer of type 'named_dt_t' (aka 'struct named_dt_t')
with these two tests:
H5REPACK-committed_dt_DFF
H5REPACK-committed_dt
Reformulated per @gnuoyd suggestion.
* Fixed undefined float -> unsigned char conversion in HL_test_image
* Removed dead skip_overflow_tests_g global
The global `skip_overflow_tests_g` was being set but never read.
* Don't treat 2d array as 1d array, fixing UBSan complaint in `CPP_testhdf5`
* Committing clang-format changes
* Remove extra ']' in line 730.
* Committing clang-format changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
Diffstat (limited to 'c++')
-rw-r--r-- | c++/test/ttypes.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index b633740..7d0337d 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -656,7 +656,6 @@ static void test_named() { static hsize_t ds_size[2] = {10, 20}; - hsize_t i; unsigned attr_data[10][20]; DataType * ds_type = NULL; @@ -726,8 +725,11 @@ test_named() // It should be possible to define an attribute for the named type Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space); - for (i = 0; i < ds_size[0] * ds_size[1]; i++) - attr_data[0][i] = (int)i; /*tricky*/ + for (hsize_t i = 0; i < ds_size[0]; i++) { + for (hsize_t j = 0; j < ds_size[1]; j++) { + attr_data[i][j] = (unsigned)(i * ds_size[1] + j); + } + } attr1.write(PredType::NATIVE_UINT, attr_data); attr1.close(); |