summaryrefslogtreecommitdiffstats
path: root/src/H5Gtraverse.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-10-02 20:00:21 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-10-02 20:00:21 (GMT)
commit22be11f0d9cd3e0e366b2b4dfe14933fdcf3687e (patch)
tree4509bae15cd445b09e38584d5bee2b2fc27ae67a /src/H5Gtraverse.c
parentfa94f16ad894ccbd3ab5b3a7a0f9bf74c6ea4d9e (diff)
downloadhdf5-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/H5Gtraverse.c')
-rw-r--r--src/H5Gtraverse.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index 80d02cb..4fc345c 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -607,13 +607,15 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target,
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset location")
/* Check for needing a larger buffer for the individual path name components */
- if(HDstrlen(name) + 1 > H5G_comp_alloc_g) {
- H5G_comp_alloc_g = MAX3(1024, 2 * H5G_comp_alloc_g, HDstrlen(name) + 1);
- H5G_comp_g = H5MM_realloc(H5G_comp_g, H5G_comp_alloc_g);
- if(!H5G_comp_g) {
- H5G_comp_alloc_g = 0;
+ if((HDstrlen(name) + 1) > H5G_comp_alloc_g) {
+ char *new_comp; /* New component buffer */
+ size_t new_alloc; /* New component buffer size */
+
+ new_alloc = MAX3(1024, (2 * H5G_comp_alloc_g), (HDstrlen(name) + 1));
+ if(NULL == (new_comp = H5MM_realloc(H5G_comp_g, new_alloc)))
HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "unable to allocate component buffer")
- } /* end if */
+ H5G_comp_g = new_comp;
+ H5G_comp_alloc_g = new_alloc;
} /* end if */
/* Traverse the path */