Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few Clang sanitizer warnings #1727

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/H5Tconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3266,9 +3266,10 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, si
/* If we're down to the last few elements, just wrap up */
/* with a "real" reverse copy */
if (safe < 2) {
s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride;
d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride;
b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride;
s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride;
d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride;
if (bkg)
b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride;
s_stride = -s_stride;
d_stride = -d_stride;
b_stride = -b_stride;
Expand All @@ -3278,7 +3279,8 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, si
else {
s = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride;
d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride;
b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride;
if (bkg)
b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do arithmetic on bkg if bkg is a NULL pointer.

} /* end else */
} /* end if */
else {
Expand Down Expand Up @@ -3426,7 +3428,9 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, si
/* Advance pointers */
s += s_stride;
d += d_stride;
b += b_stride;

if (b)
b += b_stride;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do arithmetic on b if b is a NULL pointer.

} /* end for */

/* Decrement number of elements left to convert */
Expand Down Expand Up @@ -3716,9 +3720,10 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
/* If we're down to the last few elements, just wrap up */
/* with a "real" reverse copy */
if (safe < 2) {
s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride;
d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride;
b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride;
s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride;
d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride;
if (bkg)
b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride;
s_stride = -s_stride;
d_stride = -d_stride;
b_stride = -b_stride;
Expand All @@ -3728,7 +3733,8 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
else {
s = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride;
d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride;
b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride;
if (bkg)
b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride;
} /* end else */
} /* end if */
else {
Expand Down Expand Up @@ -3796,7 +3802,9 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
/* Advance pointers */
s += s_stride;
d += d_stride;
b += b_stride;

if (b)
b += b_stride;
} /* end for */

/* Decrement number of elements left to convert */
Expand Down
7 changes: 5 additions & 2 deletions src/H5VLdyn_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ H5VL__term_opt_operation(void)
FUNC_ENTER_PACKAGE_NOERR

/* Iterate over the VOL subclasses */
for (subcls = 0; subcls < NELMTS(H5VL_opt_vals_g); subcls++)
if (H5VL_opt_ops_g[subcls])
for (subcls = 0; subcls < NELMTS(H5VL_opt_vals_g); subcls++) {
if (H5VL_opt_ops_g[subcls]) {
H5SL_destroy(H5VL_opt_ops_g[subcls], H5VL__term_opt_operation_cb, NULL);
H5VL_opt_ops_g[subcls] = NULL;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set dynamic operations skip list array table entries to NULL to avoid a use after free during package termination.

}
}

FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5VL__term_opt_operation() */
Expand Down
15 changes: 9 additions & 6 deletions test/dsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -12514,10 +12514,13 @@ test_bt2_hdr_fd(const char *env_h5_driver, hid_t fapl)
hid_t dcpl = -1;
hid_t msid = -1;
H5D_chunk_index_t idx_type;
const hsize_t shape[2] = {8, 8};
const hsize_t maxshape[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
const hsize_t chunk[2] = {8, 8};
const int buffer[8] = {0, 1, 2, 3, 4, 5, 6, 7};
const hsize_t shape[2] = {8, 8};
const hsize_t maxshape[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
const hsize_t chunk[2] = {8, 8};
const int buffer[8][8] = {{0, 1, 2, 3, 4, 5, 6, 7}, {8, 9, 10, 11, 12, 13, 14, 15},
{16, 17, 18, 19, 20, 21, 22, 23}, {24, 25, 26, 27, 28, 29, 30, 31},
{32, 33, 34, 35, 36, 37, 38, 39}, {40, 41, 42, 43, 44, 45, 46, 47},
{48, 49, 50, 51, 52, 53, 54, 55}, {56, 57, 58, 59, 60, 61, 62, 63}};
H5O_info2_t info;

TESTING("Version 2 B-tree chunk index header flush dependencies handled correctly");
Expand Down Expand Up @@ -15267,8 +15270,8 @@ test_h5s_plist(void)
/* Attempt to 'OR' block with invalid dimensions into the selection */
H5E_BEGIN_TRY
{
ret = H5Pset_dataset_io_hyperslab_selection(dxpl_id_copy, 2, H5S_SELECT_OR, &start, &stride, &count,
&block);
ret = H5Pset_dataset_io_hyperslab_selection(dxpl_id_copy, H5S_MAX_RANK + 1, H5S_SELECT_OR, &start,
&stride, &count, &block);
}
H5E_END_TRY;
if (ret == SUCCEED)
Expand Down