Merge pull request #1588 in HDFFV/hdf5 from ~SONGYULU/hdf5_ray:HDFFV-10705-memory-leak-in-scale-offset to develop

* commit 'b23079de3af4bfb7aa0508fb81aacd67a76c2114':
  HDFFV-10705: Fixed memory leak in scale offset filter.
This commit is contained in:
Ray Lu 2019-03-01 11:32:14 -06:00
commit 5182e73d5e

View File

@ -1174,6 +1174,8 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value
/* special case: minbits equal to full precision */ /* special case: minbits equal to full precision */
if(minbits == p.size * 8) { if(minbits == p.size * 8) {
HDmemcpy(outbuf, (unsigned char*)(*buf)+buf_offset, size_out); HDmemcpy(outbuf, (unsigned char*)(*buf)+buf_offset, size_out);
/* free the original buffer */
H5MM_xfree(*buf);
/* convert to dataset datatype endianness order if needed */ /* convert to dataset datatype endianness order if needed */
if(need_convert) if(need_convert)
@ -1272,6 +1274,9 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value
/* special case: minbits equal to full precision */ /* special case: minbits equal to full precision */
if(minbits == p.size * 8) { if(minbits == p.size * 8) {
HDmemcpy(outbuf + buf_offset, *buf, nbytes); HDmemcpy(outbuf + buf_offset, *buf, nbytes);
/* free the original buffer */
H5MM_xfree(*buf);
*buf = outbuf; *buf = outbuf;
outbuf = NULL; outbuf = NULL;
*buf_size = size_out; *buf_size = size_out;