summaryrefslogtreecommitdiffstats
path: root/src/H5Aint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-12-10 12:36:56 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-12-10 12:36:56 (GMT)
commit34d14bdf89d63023dfeb5ff471b71e5b591faa31 (patch)
tree64aa9fbfe2b3e011b55b39c70b4f85cc28c3a9c9 /src/H5Aint.c
parentadce7dfd846901f3164d446cf7443747ddefc492 (diff)
downloadhdf5-34d14bdf89d63023dfeb5ff471b71e5b591faa31.zip
hdf5-34d14bdf89d63023dfeb5ff471b71e5b591faa31.tar.gz
hdf5-34d14bdf89d63023dfeb5ff471b71e5b591faa31.tar.bz2
[svn-r17980] Description:
Bring Coverity changes into the trunk: (also other minor cleanups) r17955: Fix Coverity item 24. Add missing error condition to H5AC_ext_config_2_int_config. r17956: Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb. r17957: Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb. r17958: Fix Coverity item 117. Fix error handling in H5B_shared_new. r17959: Fix Coverity item 209. Added an assertion for leaf->shared in H5B2_cache_leaf_dest. r17960: Fix Coverity item 208. Added an assertion for internal->shared in H5B2_cache_internal_dest. r17961: Fix Coverity item 89. Reworked the code to avoid array overrun in H5C__autoadjust__ageout__insert_new_marker. r17962: Fix for coverity Resource_leak 195,203,204,205. r17963: Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug. r17964: Fix Coverity issues #197, 198 & 199: memory not being released. (Also clean up other resource leaks in nearby and/or similar code). r17965: Fix Coverity issue #151: release resources on error r17966: Fix Coverity issue #187: Remove leftover code remnant from prior bugfix which was causing resource leak of open files. r17967: Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and added comparison of length of path parameter to the size of the destination buffer in h5import.h/h5import.c. r17968: Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy. r17969: Fix for coverity Resource_leak #196. r17970: Coverity 167-173: Initialized pointer of buffers. In error handling, closed types and free memory. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5Aint.c')
-rw-r--r--src/H5Aint.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c
index d63b5f0..a89c1c9 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -150,32 +150,21 @@ H5A_compact_build_table_cb(H5O_t UNUSED *oh, H5O_mesg_t *mesg/*in,out*/,
/* Re-allocate the table if necessary */
if(udata->curr_attr == udata->atable->nattrs) {
- size_t i;
- size_t n = MAX(1, 2 * udata->atable->nattrs);
- H5A_t **table = (H5A_t **)H5FL_SEQ_CALLOC(H5A_t_ptr, n);
-
- /* Use attribute functions for operation */
- for(i=0; i<udata->atable->nattrs; i++) {
- table[i] = (H5A_t *)H5FL_CALLOC(H5A_t);
- if(NULL == H5A_copy(table[i], udata->atable->attrs[i]))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute")
- if(H5A_close(udata->atable->attrs[i]) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close attribute")
- }
-
- if(udata->atable->nattrs)
- udata->atable->attrs = (H5A_t **)H5FL_SEQ_FREE(H5A_t_ptr, udata->atable->attrs);
+ H5A_t **new_table; /* New table for attributes */
+ size_t new_table_size; /* Number of attributes in new table */
- if(!table)
+ /* Allocate larger table */
+ new_table_size = MAX(1, 2 * udata->atable->nattrs);
+ if(NULL == (new_table = (H5A_t **)H5FL_SEQ_REALLOC(H5A_t_ptr, udata->atable->attrs, new_table_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "unable to extend attribute table")
- udata->atable->attrs = table;
- udata->atable->nattrs = n;
+
+ /* Update table information in user data */
+ udata->atable->attrs = new_table;
+ udata->atable->nattrs = new_table_size;
} /* end if */
/* Copy attribute into table */
- udata->atable->attrs[udata->curr_attr] = (H5A_t *)H5FL_CALLOC(H5A_t);
-
- if(NULL == H5A_copy(udata->atable->attrs[udata->curr_attr], (const H5A_t *)mesg->native))
+ if(NULL == (udata->atable->attrs[udata->curr_attr] = H5A_copy(NULL, (const H5A_t *)mesg->native)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute")
/* Assign [somewhat arbitrary] creation order value, if requested */