From 2f2197fb149f361b8c9f27221875efccdccfca2c Mon Sep 17 00:00:00 2001 From: jhendersonHDF Date: Fri, 18 Aug 2023 16:00:43 -0500 Subject: [PATCH] Fix valgrind warning about write of uninitialized bytes in ScaleOffset filter (#3390) --- src/H5Zscaleoffset.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 123c767ff3a..c3de6a62d66 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -1283,6 +1283,9 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu } /* output; compress */ else { + size_t used_bytes; + size_t unused_bytes; + assert(nbytes == d_nelmts * p.size); /* before preprocess, convert to memory endianness order if needed */ @@ -1334,7 +1337,10 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu /* (Looks like an error in the original determination of how many * bytes would be needed for parameters. - QAK, 2010/08/19) */ - memset(outbuf + 13, 0, (size_t)8); + used_bytes = 4 + 1 + sizeof(unsigned long long); + assert(used_bytes <= size_out); + unused_bytes = size_out - used_bytes; + memset(outbuf + 13, 0, unused_bytes); /* special case: minbits equal to full precision */ if (minbits == p.size * 8) {