Skip to content

Commit

Permalink
Fixes a minor valgrind issue in the chunk_info test (#675)
Browse files Browse the repository at this point in the history
* Fixes a minor valgrind issue in the chunk_info test

The chunk_info test incorrectly set the number of bytes in a compressed
buffer, which caused valgrind to complain about writing uninitialized
bytes.

* Committing clang-format changes

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
derobins and github-actions[bot] authored May 21, 2021
1 parent 9ed46a4 commit 8a3dfc1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/chunk_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ verify_idx_nchunks(hid_t dset, hid_t dspace, H5D_chunk_index_t exp_idx_type, hsi
* Return: Success: SUCCEED
* Failure: FAIL
*
* Note: Note that the dataspace argument in these new functions are
* Note: Note that the dataspace argument in these new functions is
* currently not used. The functionality involved the dataspace
* will be implemented in the next version.
*
Expand Down Expand Up @@ -486,10 +486,10 @@ test_get_chunk_info_highest_v18(hid_t fapl)
hsize_t offset[2] = {0, 0}; /* Offset coordinates of a chunk */
#ifdef H5_HAVE_FILTER_DEFLATE
const Bytef *z_src = (const Bytef *)(direct_buf);
Bytef * z_dst; /*destination buffer */
Bytef * z_dst; /* Destination buffer */
uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(CHK_SIZE);
uLong z_src_nbytes = (uLong)CHK_SIZE;
#endif /* end H5_HAVE_FILTER_DEFLATE */
#endif
void * inbuf = NULL; /* Pointer to new buffer */
hsize_t chunk_size = CHK_SIZE; /* Size of a chunk, can be compressed or not */
hsize_t ii, jj; /* Array indices */
Expand Down Expand Up @@ -544,14 +544,15 @@ test_get_chunk_info_highest_v18(hid_t fapl)
/* Allocate input (compressed) buffer */
inbuf = HDmalloc(z_dst_nbytes);

/* Set chunk size to the compressed chunk size and the chunk point
to the compressed data chunk */
chunk_size = (hsize_t)z_dst_nbytes;
z_dst = (Bytef *)inbuf;
/* zlib-friendly alias for the input buffer */
z_dst = (Bytef *)inbuf;

/* Perform compression from the source to the destination buffer */
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);

/* Set the chunk size to the compressed chunk size */
chunk_size = (hsize_t)z_dst_nbytes;

/* Check for various zlib errors */
if (Z_BUF_ERROR == ret) {
HDfprintf(stderr, "overflow");
Expand Down

0 comments on commit 8a3dfc1

Please sign in to comment.