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/H5Gname.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/H5Gname.c')
-rw-r--r-- | src/H5Gname.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/H5Gname.c b/src/H5Gname.c index a041dcd..2bc0174 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -1079,8 +1079,11 @@ H5G_refname_iterator(hid_t group, const char *name, const H5L_info_t *link_info, /* Build the object's full name */ len_needed = HDstrlen(udata->container) + HDstrlen(name) + 2; if(len_needed > udata->max_container_len) { - if(NULL == (udata->container = H5MM_realloc(udata->container, len_needed))) + void *new_container; /* Pointer to new container */ + + if(NULL == (new_container = H5MM_realloc(udata->container, len_needed))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate path string") + udata->container = new_container; udata->max_container_len = len_needed; } /* end if */ HDstrcat(udata->container, name); @@ -1129,8 +1132,11 @@ H5G_refname_iterator(hid_t group, const char *name, const H5L_info_t *link_info, len = HDstrlen(udata->container); len_needed = len + HDstrlen(name) + 2; if(len_needed > udata->max_container_len) { - if(NULL == (udata->container = H5MM_realloc(udata->container, len_needed))) + void *new_container; /* Pointer to new container */ + + if(NULL == (new_container = H5MM_realloc(udata->container, len_needed))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate path string") + udata->container = new_container; udata->max_container_len = len_needed; } /* end if */ if(!udata->is_root_group) |