summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-08-25 21:49:31 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-08-25 21:49:31 (GMT)
commita8b272ac257ccbdf4da13423b5175ba22e7d3c14 (patch)
treebfd12edf153271c8e84e18b8dd7ada28f89a62b5 /src
parent5a1bb020a3a0f84883ac11098d801e3f9a84b3ad (diff)
downloadhdf5-a8b272ac257ccbdf4da13423b5175ba22e7d3c14.zip
hdf5-a8b272ac257ccbdf4da13423b5175ba22e7d3c14.tar.gz
hdf5-a8b272ac257ccbdf4da13423b5175ba22e7d3c14.tar.bz2
[svn-r11300] Purpose:
Code cleanup Description: Prevent memory leak when too many links are traversed. Also add test to traverse too many links. Platforms tested: FreeBSD 4.11 (sleipnir) Linux 2.4
Diffstat (limited to 'src')
-rw-r--r--src/H5G.c5
-rw-r--r--src/H5Gprivate.h1
2 files changed, 4 insertions, 2 deletions
diff --git a/src/H5G.c b/src/H5G.c
index eff793d..0690039 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -110,7 +110,6 @@
#define H5G_INIT_HEAP 8192
#define H5G_RESERVED_ATOMS 0
#define H5G_SIZE_HINT 256 /*default root grp size hint */
-#define H5G_NLINKS 16 /*max symlinks to follow per lookup */
/*
* During name lookups (see H5G_namei()) we sometimes want information about
@@ -1455,6 +1454,7 @@ H5G_namei(const H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/
const char *s = NULL;
unsigned null_obj; /* Flag to indicate this function was called with obj_ent set to NULL */
unsigned null_grp; /* Flag to indicate this function was called with grp_ent set to NULL */
+ unsigned obj_copy = 0; /* Flag to indicate that the object entry is copied */
unsigned group_copy = 0; /* Flag to indicate that the group entry is copied */
unsigned last_comp = 0; /* Flag to indicate that a component is the last component in the name */
unsigned did_insert = 0; /* Flag to indicate that H5G_stab_insert was called */
@@ -1504,6 +1504,7 @@ H5G_namei(const H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/
/* Deep copy of the symbol table entry (duplicates strings) */
if (H5G_ent_copy(obj_ent, loc_ent,H5G_COPY_DEEP)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
+ obj_copy = 1;
H5G_ent_reset(grp_ent);
@@ -1646,7 +1647,7 @@ H5G_namei(const H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/
done:
/* If we started with a NULL obj_ent, free the entry information */
- if(null_obj)
+ if(null_obj || (ret_value < 0 && obj_copy))
H5G_free_ent_name(obj_ent);
/* If we started with a NULL grp_ent and we copied something into it, free the entry information */
if(null_grp && group_copy)
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index 92fee2d..f105463 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -50,6 +50,7 @@
#define H5G_NODE_MAGIC "SNOD" /*symbol table node magic number */
#define H5G_NODE_SIZEOF_MAGIC 4 /*sizeof symbol node magic number */
#define H5G_NO_CHANGE (-1) /*see H5G_ent_modified() */
+#define H5G_NLINKS 16 /*max symlinks to follow per lookup */
/*
* The disk size for a symbol table entry...