diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-02 14:55:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-02 14:55:35 (GMT) |
commit | cba7dd0ddde3711058ae3854ece47928aaa0235d (patch) | |
tree | 05eac6a4b1bf464f084fdbc9e347c1fd73c0a222 /src/H5Zdeflate.c | |
parent | 5c081f2baa778542d14a8e1ffb4971aa89476b35 (diff) | |
download | hdf5-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)
Diffstat (limited to 'src/H5Zdeflate.c')
-rw-r--r-- | src/H5Zdeflate.c | 11 |
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); |