diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2000-04-11 18:21:27 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2000-04-11 18:21:27 (GMT) |
commit | 1dbee0210fc53e8d553ca6ec9510e020b08698aa (patch) | |
tree | df96af8ba99a33dbd9713abea8e4a0823beb79c0 /src/H5I.c | |
parent | 4e89f86c9756191c970749206563ac65b3c8d784 (diff) | |
download | hdf5-1dbee0210fc53e8d553ca6ec9510e020b08698aa.zip hdf5-1dbee0210fc53e8d553ca6ec9510e020b08698aa.tar.gz hdf5-1dbee0210fc53e8d553ca6ec9510e020b08698aa.tar.bz2 |
[svn-r2108] Fixed small bug where we were reading a value out of a piece of memory we'd
just free'd. A small bug, but it will cause problems in a threaded
environment. (And it was filling up the purify logfile with junk.. :-)
Diffstat (limited to 'src/H5I.c')
-rw-r--r-- | src/H5I.c | 52 |
1 files changed, 28 insertions, 24 deletions
@@ -760,45 +760,49 @@ H5I_remove(hid_t id) /* Check arguments */ grp = H5I_GROUP(id); - if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_DONE(NULL); + if (grp <= H5I_BADID || grp >= H5I_NGROUPS) + HGOTO_DONE(NULL); grp_ptr = H5I_id_group_list_g[grp]; - if (grp_ptr == NULL || grp_ptr->count <= 0) HGOTO_DONE(NULL); + if (grp_ptr == NULL || grp_ptr->count <= 0) + HGOTO_DONE(NULL); /* Get the bucket in which the ID is located */ hash_loc = (uintn) H5I_LOC(id, grp_ptr->hash_size); curr_id = grp_ptr->id_list[hash_loc]; - if (curr_id == NULL) HGOTO_DONE(NULL); + if (curr_id == NULL) + HGOTO_DONE(NULL); last_id = NULL; while (curr_id != NULL) { - if (curr_id->id == id) break; - last_id = curr_id; - curr_id = curr_id->next; - } - - if (curr_id != NULL) { - if (last_id == NULL) { - /* ID is the first in the chain */ - grp_ptr->id_list[hash_loc] = curr_id->next; - } else { - last_id->next = curr_id->next; - } - ret_value = curr_id->obj_ptr; - H5FL_FREE(H5I_id_info_t,curr_id); - } else { - /* couldn't find the ID in the proper place */ - HGOTO_DONE(NULL); + if (curr_id->id == id) + break; + last_id = curr_id; + curr_id = curr_id->next; } #ifdef IDS_ARE_CACHED /* Delete object from cache */ for (i = 0; i < ID_CACHE_SIZE; i++) - if (H5I_cache_g[i] && H5I_cache_g[i]->id == id) { - H5I_cache_g[i] = NULL; - break; /* we assume there is only one instance in the cache */ - } + if (H5I_cache_g[i] && H5I_cache_g[i]->id == id) { + H5I_cache_g[i] = NULL; + break; /* we assume there is only one instance in the cache */ + } #endif /* IDS_ARE_CACHED */ + if (curr_id != NULL) { + if (last_id == NULL) { + /* ID is the first in the chain */ + grp_ptr->id_list[hash_loc] = curr_id->next; + } else { + last_id->next = curr_id->next; + } + ret_value = curr_id->obj_ptr; + H5FL_FREE(H5I_id_info_t,curr_id); + } else { + /* couldn't find the ID in the proper place */ + HGOTO_DONE(NULL); + } + /* Decrement the number of IDs in the group */ (grp_ptr->ids)--; |