summaryrefslogtreecommitdiffstats
path: root/src/H5Olink.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/H5Olink.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/H5Olink.c')
-rw-r--r--src/H5Olink.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/H5Olink.c b/src/H5Olink.c
index 53fa99e..039184d 100644
--- a/src/H5Olink.c
+++ b/src/H5Olink.c
@@ -165,7 +165,7 @@ H5O_link_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
p += len;
break;
- /* User-defined linkes */
+ /* User-defined links */
default:
if(lnk->type < H5L_LINK_UD_MIN || lnk->type > H5L_LINK_MAX)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unknown link type")
@@ -180,6 +180,8 @@ H5O_link_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
HDmemcpy(lnk->u.ud.udata, p, len);
p += len;
}
+ else
+ lnk->u.ud.udata = NULL;
} /* end switch */
/* Set return value */
@@ -192,6 +194,8 @@ done:
H5MM_xfree(lnk->name);
if(lnk->type == H5L_LINK_SOFT && lnk->u.soft.name != NULL)
H5MM_xfree(lnk->u.soft.name);
+ if(lnk->type >= H5L_LINK_UD_MIN && lnk->u.ud.size > 0 && lnk->u.ud.udata != NULL)
+ H5MM_xfree(lnk->u.ud.udata);
H5FL_FREE(H5O_link_t, lnk);
} /* end if */
@@ -323,7 +327,7 @@ H5O_link_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags)
if(lnk->type == H5L_LINK_SOFT)
dest->u.soft.name = H5MM_xstrdup(lnk->u.soft.name);
else if(lnk->type >= H5L_LINK_UD_MIN) {
- if(lnk->u.ud.size != 0)
+ if(lnk->u.ud.size > 0)
{
if(NULL == (dest->u.ud.udata = H5MM_malloc(lnk->u.ud.size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
@@ -601,8 +605,8 @@ H5O_link_copy_file(H5F_t UNUSED *file_src, void *native_src, H5F_t UNUSED *file_
default:
if(link_src->type >= H5L_LINK_UD_MIN)
{
- /* Copy the user-defined link's user data */
- if(link_src->u.ud.size != 0)
+ /* Copy the user-defined link's user data if it exists */
+ if(link_src->u.ud.size > 0)
{
if(NULL == (link_dst->u.ud.udata = H5MM_malloc(link_src->u.ud.size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")