summaryrefslogtreecommitdiffstats
path: root/src/H5Zscaleoffset.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Zscaleoffset.c')
-rw-r--r--src/H5Zscaleoffset.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c
index 4bfc8b1..eb3c6e6 100644
--- a/src/H5Zscaleoffset.c
+++ b/src/H5Zscaleoffset.c
@@ -806,6 +806,11 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id)
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+#ifdef H5_CLEAR_MEMORY
+ /* Initialize the parameters to a known state */
+ HDmemset(cd_values, 0, sizeof(cd_values));
+#endif /* H5_CLEAR_MEMORY */
+
/* Get the filter's current parameters */
if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SCALEOFFSET, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get scaleoffset parameters")
@@ -1182,6 +1187,14 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value
for(i = 0; i < sizeof(unsigned long long); i++)
((unsigned char *)outbuf)[5+i] = (unsigned char)((minval & ((unsigned long long)0xff << i*8)) >> i*8);
+#ifdef H5_CLEAR_MEMORY
+ /* Zero out remaining, unused bytes */
+ /* (Looks like an error in the original determination of how many
+ * bytes would be needed for parameters. - QAK, 2010/08/19)
+ */
+ HDmemset(outbuf + 13, 0, (size_t)8);
+#endif /* H5_CLEAR_MEMORY */
+
/* special case: minbits equal to full precision */
if(minbits == p.size * 8) {
HDmemcpy(outbuf + buf_offset, *buf, nbytes);