diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-02 20:00:21 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-02 20:00:21 (GMT) |
commit | 22be11f0d9cd3e0e366b2b4dfe14933fdcf3687e (patch) | |
tree | 4509bae15cd445b09e38584d5bee2b2fc27ae67a /src/H5Distore.c | |
parent | fa94f16ad894ccbd3ab5b3a7a0f9bf74c6ea4d9e (diff) | |
download | hdf5-22be11f0d9cd3e0e366b2b4dfe14933fdcf3687e.zip hdf5-22be11f0d9cd3e0e366b2b4dfe14933fdcf3687e.tar.gz hdf5-22be11f0d9cd3e0e366b2b4dfe14933fdcf3687e.tar.bz2 |
[svn-r14175] Description:
Minor fixes to avoid memory leaks when 'realloc' fails.
Tested on:
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5Distore.c')
-rw-r--r-- | src/H5Distore.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/H5Distore.c b/src/H5Distore.c index 687e6d6..66fc41a 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -1015,12 +1015,16 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key, /* Resize the buf if it is too small to hold the data */ if(nbytes > buf_size) { + void *new_buf; /* New buffer for data */ + /* Re-allocate memory for copying the chunk */ - if(NULL == (udata->buf = H5MM_realloc(udata->buf, nbytes))) + if(NULL == (new_buf = H5MM_realloc(udata->buf, nbytes))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk") + udata->buf = new_buf; if(udata->bkg) { - if(NULL == (udata->bkg = H5MM_realloc(udata->bkg, nbytes))) + if(NULL == (new_buf = H5MM_realloc(udata->bkg, nbytes))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk") + udata->bkg = new_buf; if(!udata->cpy_info->expand_ref) HDmemset((uint8_t *)udata->bkg + buf_size, 0, (size_t)(nbytes - buf_size)); |