diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-07-17 02:46:42 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-07-17 02:46:42 (GMT) |
commit | 96a49c0d37ea736422c2cffe4bd22f0209e4fe24 (patch) | |
tree | 1be71f9a8081383666c91a3a5837c064fa7aaa59 /src/H5T.c | |
parent | 5e98b5bb36c9e0b1078e56d9b734657fcfe7a03d (diff) | |
download | hdf5-96a49c0d37ea736422c2cffe4bd22f0209e4fe24.zip hdf5-96a49c0d37ea736422c2cffe4bd22f0209e4fe24.tar.gz hdf5-96a49c0d37ea736422c2cffe4bd22f0209e4fe24.tar.bz2 |
[svn-r11078] Purpose:
Bug fix
Description:
Correct memory leak when a dataset is attempted to be opened, but turns
out to be a group or named datatype.
Also, clean up code that was leading to the leak and zero out empty
group entries to help prevent similar errors in the future.
Platforms tested:
FreebSD 4.11 (sleipnir)
Too minor to require h5committest
Diffstat (limited to 'src/H5T.c')
-rw-r--r-- | src/H5T.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1578,6 +1578,7 @@ H5Topen(hid_t loc_id, const char *name) H5T_t *type = NULL; H5G_entry_t *loc = NULL; H5G_entry_t ent; + hbool_t ent_found = FALSE; /* Entry at 'name' found */ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */ hid_t ret_value =FAIL; @@ -1596,6 +1597,7 @@ H5Topen(hid_t loc_id, const char *name) */ if (H5G_find (loc, name, NULL, &ent/*out*/, dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found"); + ent_found = TRUE; /* Check that the object found is the correct type */ if (H5G_get_type(&ent, dxpl_id) != H5G_TYPE) @@ -1610,9 +1612,14 @@ H5Topen(hid_t loc_id, const char *name) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named data type"); done: - if(ret_value<0) + if(ret_value<0) { if(type!=NULL) H5T_close(type); + else { + if(ent_found && ent.header) + H5G_free_ent_name(&ent); + } /* end else */ + } /* end if */ FUNC_LEAVE_API(ret_value); } @@ -3052,7 +3059,7 @@ H5T_open (H5G_entry_t *ent, hid_t dxpl_id) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found"); /* Add the datatype to the list of opened objects in the file */ - if(H5FO_insert(ent->file, ent->header, dt->shared)<0) + if(H5FO_insert(dt->ent.file, dt->ent.header, dt->shared)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects") /* Mark any datatypes as being in memory now */ |