summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-10-02 14:55:35 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-10-02 14:55:35 (GMT)
commitcba7dd0ddde3711058ae3854ece47928aaa0235d (patch)
tree05eac6a4b1bf464f084fdbc9e347c1fd73c0a222
parent5c081f2baa778542d14a8e1ffb4971aa89476b35 (diff)
downloadhdf5-cba7dd0ddde3711058ae3854ece47928aaa0235d.zip
hdf5-cba7dd0ddde3711058ae3854ece47928aaa0235d.tar.gz
hdf5-cba7dd0ddde3711058ae3854ece47928aaa0235d.tar.bz2
[svn-r14170] Description:
Avoid memory leak when realloc() fails during attempt to get larger buffer as we are decompressing deflated data. Tested on: FreeBSD/32 6.2 (duty) Linux/32 2.6 (kagiso)
-rw-r--r--src/H5Zdeflate.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c
index 3c3678c..56b910b 100644
--- a/src/H5Zdeflate.c
+++ b/src/H5Zdeflate.c
@@ -118,18 +118,21 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
}
else {
/* If we're not done and just ran out of buffer space, get more */
- if (0==z_strm.avail_out) {
+ if(0 == z_strm.avail_out) {
+ void *new_outbuf; /* Pointer to new output buffer */
+
/* Allocate a buffer twice as big */
nalloc *= 2;
- if (NULL==(outbuf = H5MM_realloc(outbuf, nalloc))) {
+ if(NULL == (new_outbuf = H5MM_realloc(outbuf, nalloc))) {
(void)inflateEnd(&z_strm);
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression")
- }
+ } /* end if */
+ outbuf = new_outbuf;
/* Update pointers to buffer for next set of uncompressed data */
z_strm.next_out = (unsigned char*)outbuf + z_strm.total_out;
z_strm.avail_out = (uInt)(nalloc - z_strm.total_out);
- }
+ } /* end if */
} /* end else */
} while(status==Z_OK);