summaryrefslogtreecommitdiffstats
path: root/src/H5Gstab.c
diff options
context:
space:
mode:
authorElena Pourmal <epourmal@hdfgroup.org>2006-09-05 23:36:01 (GMT)
committerElena Pourmal <epourmal@hdfgroup.org>2006-09-05 23:36:01 (GMT)
commitd553c60eb0428adaa3b1d9c647a1b465b65b8408 (patch)
tree8ec4ab3b924f14a9f78f53402b7405976b055a80 /src/H5Gstab.c
parent46467e91b0c96f368b2ac75569dfab2d3a097ef8 (diff)
downloadhdf5-d553c60eb0428adaa3b1d9c647a1b465b65b8408.zip
hdf5-d553c60eb0428adaa3b1d9c647a1b465b65b8408.tar.gz
hdf5-d553c60eb0428adaa3b1d9c647a1b465b65b8408.tar.bz2
[svn-r12650] Description:
Purify found some memory leaks in the code related to the HDF5 external links. James provided the fix and asked me to check it in. Tested: heping, mir, shanti, and juniper
Diffstat (limited to 'src/H5Gstab.c')
-rw-r--r--src/H5Gstab.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 926aa0e..5f52b16 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -646,19 +646,24 @@ H5G_stab_lookup_cb(const H5G_entry_t *ent, void *_udata)
data_size =ent->cache.ulink.udata_size;
+ /* If there is user data, allocate space for it and copy it from the heap */
if(data_size > 0)
{
s = H5HL_offset_into(udata->file, heap, ent->cache.ulink.udata_offset);
- /* Allocate space for the user data and copy it from the heap */
- udata->lnk->u.ud.udata = H5MM_malloc(data_size);
- HDmemcpy(udata->lnk->u.ud.udata, s, data_size);
+ udata->lnk->u.ud.udata = H5MM_malloc(data_size);
+ HDmemcpy(udata->lnk->u.ud.udata, s, data_size);
} /* end if */
+ else
+ udata->lnk->u.ud.udata = NULL;
/* Release the local heap */
if(H5HL_unprotect(udata->file, udata->dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0)
+ {
+ /* Release allocated memory before exiting */
+ H5MM_free(udata->lnk->u.ud.udata);
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read unprotect link value")
-
+ }
/* Set link size and type */
udata->lnk->u.ud.size = data_size;
udata->lnk->type = ent->cache.ulink.link_type;