mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-01 16:28:09 +08:00
[svn-r7053] Purpose:
Bug fix. Description: When a duplicate object was attempted to be created, the library would leak file memory and object references in the file, potentially causing an infinite loop when shutting the library down. Solution: Clean up after ourselves... :-) Platforms tested: FreeBSD 4.8 (sleipnir) h5committest
This commit is contained in:
parent
780d678ddd
commit
4e3716dd66
15
src/H5G.c
15
src/H5G.c
@ -1678,9 +1678,10 @@ done:
|
||||
static H5G_t *
|
||||
H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id)
|
||||
{
|
||||
H5G_t *grp = NULL; /*new group */
|
||||
H5F_t *file; /* File new group will be in */
|
||||
H5G_t *ret_value; /* Return value */
|
||||
H5G_t *grp = NULL; /*new group */
|
||||
H5F_t *file; /* File new group will be in */
|
||||
unsigned stab_init=0; /* Flag to indicate that the symbol stable was created successfully */
|
||||
H5G_t *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5G_create, NULL);
|
||||
|
||||
@ -1699,6 +1700,7 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id)
|
||||
/* Create the group entry */
|
||||
if (H5G_stab_create(file, dxpl_id, size_hint, &(grp->ent)/*out*/) < 0)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create grp");
|
||||
stab_init=1; /* Indicate that the symbol table information is valid */
|
||||
|
||||
/* insert child name into parent */
|
||||
if(H5G_insert(loc,name,&(grp->ent), dxpl_id)<0)
|
||||
@ -1711,6 +1713,13 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id)
|
||||
|
||||
done:
|
||||
if(ret_value==NULL) {
|
||||
/* Check if we need to release the file-oriented symbol table info */
|
||||
if(stab_init) {
|
||||
if(H5O_close(&(grp->ent))<0)
|
||||
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release object header");
|
||||
if(H5O_delete(file, dxpl_id,grp->ent.header)<0)
|
||||
HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header");
|
||||
} /* end if */
|
||||
if(grp!=NULL)
|
||||
H5FL_FREE(H5G_t,grp);
|
||||
} /* end if */
|
||||
|
@ -160,7 +160,10 @@ H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type, hid_t dxpl_id)
|
||||
done:
|
||||
if (ret_value<0) {
|
||||
if ((type->state==H5T_STATE_TRANSIENT || type->state==H5T_STATE_RDONLY) && H5F_addr_defined(type->ent.header)) {
|
||||
H5O_close(&(type->ent));
|
||||
if(H5O_close(&(type->ent))<0)
|
||||
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header");
|
||||
if(H5O_delete(file, dxpl_id,type->ent.header)<0)
|
||||
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header");
|
||||
type->ent.header = HADDR_UNDEF;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user