diff options
author | James Laird <jlaird@hdfgroup.org> | 2004-07-20 00:52:28 (GMT) |
---|---|---|
committer | James Laird <jlaird@hdfgroup.org> | 2004-07-20 00:52:28 (GMT) |
commit | 1b0b9048b75f333ff923cb440e30f3d6e1a96c42 (patch) | |
tree | 6651bd4de9aa288b1fbd09975b11af26d7f2489f /src/H5G.c | |
parent | b79142ca2b750b6d45e636bb138fc947a0b92e3f (diff) | |
download | hdf5-1b0b9048b75f333ff923cb440e30f3d6e1a96c42.zip hdf5-1b0b9048b75f333ff923cb440e30f3d6e1a96c42.tar.gz hdf5-1b0b9048b75f333ff923cb440e30f3d6e1a96c42.tar.bz2 |
[svn-r8898]
Purpose:
Bug Fix
Description:
Trying to create the root group or the working group ("/" or ".") fakes out
HDF5 so that it neither creates a group nor returns an error.
Solution:
H5G_namei now throws an error if it was supposed to insert but didn't.
Platforms tested:
sleipnir, Visual Studio 7 (very minor change)
Diffstat (limited to 'src/H5G.c')
-rw-r--r-- | src/H5G.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1393,6 +1393,7 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/, unsigned null_grp; /* Flag to indicate this function was called with grp_ent set to NULL */ 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 */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_namei); @@ -1515,6 +1516,7 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/, } } /* end if */ else { + did_insert = 1; if (H5G_stab_insert(grp_ent, H5G_comp_g, ent, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert name"); HGOTO_DONE(SUCCEED); @@ -1551,6 +1553,11 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/, if (rest) *rest = name; /*final null */ + /* If this was an insert, make sure that the insert function was actually + * called (this catches no-op names like "/" and ".") */ + if(action == H5G_NAMEI_INSERT && !did_insert) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group already exists"); + done: /* If we started with a NULL obj_ent, free the entry information */ if(null_obj) |