summaryrefslogtreecommitdiffstats
path: root/src/H5FSsection.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-01-23 07:11:57 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-01-23 07:11:57 (GMT)
commit346d487d16f9f7bca6e5bce758bab1c14b20b9ef (patch)
tree845153c2bb62de2f098abaea5d293532b6c63340 /src/H5FSsection.c
parentab37aae39f7754827774577a0053e1b0979b3b1d (diff)
downloadhdf5-346d487d16f9f7bca6e5bce758bab1c14b20b9ef.zip
hdf5-346d487d16f9f7bca6e5bce758bab1c14b20b9ef.tar.gz
hdf5-346d487d16f9f7bca6e5bce758bab1c14b20b9ef.tar.bz2
[svn-r18160] Description:
Bring r18159 from trunk to 1.8 branch: Bring Coverity fixes from 1/22/10 session to trunk: r18137: 219: Initialized hid_t to -1 and added close to error block. 189-191: Initialized line to NULL and added free line, and close fp to error block. r18138: 19: Moved code block for printing that the number of enums is empty to the error block. (Would never have been executed otherwise) r18139: Fix coverity item 58. Moved code related to displaying the parent of a repeated group to the else(isRoot) section, as the root group has no parent. r18140: 218: Initialized ret_value variable to -1. Because of throw Exception in default case of switch, the coverity problem would not have executed anyway. Good pratice is to initialize variables. r18141: Fix coverity item 92. Added code to H5E_register_class to free cls in case of an error. r18142: Fix coverity item 91. Added code to H5E_create_msg to free msg in case of an error. r18143: fixed issue 14, took away "if" and used #ifndef_xxx. r18144: Fix coverity item 110. Added code to H5Eget_minor to free msg_str in case of an error. r18145: fixed coverity #18 removed "aligned", it is always NULL. r18146: Fix coverity item 109. Added code to H5Eget_major to free msg_str in case of an error. r18147: Fixed coverity #81 and #82, Check for bad pointer(s), but can't issue error, just leave r18148: Fix coverity item 97. Added code to H5FD_fapl_open to free copied_driver_info in case of an error. r18149: Fix coverity item 96. Added code to H5FD_dxpl_open to free copied_driver_info in case of an error. r18150: Fix Coverity issue #29: Protected cache_ptr dereferences with "if(pass)" block r18151: Fix coverity item 93. Added code to H5FL_fac_init to free factory and new_node in case of an error. r18152: Fix coverity items 98 and 99. Added code free allocated space in case of error. r18155: 124: Freed head pointer before jumping to done. There was no error handling block and normal exit used same path out. 120-123: Freed list of lists in error handling block. r18156: Fix coverity issues 179, 180, 181, 182, 183, 184, 186, 320, 407. These were resource leak issues where allocated memory was not freed, generally in the case of tests that failed. Tested on: Mac OS X/32 10.6.2 (amazon) debug & production
Diffstat (limited to 'src/H5FSsection.c')
-rw-r--r--src/H5FSsection.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/H5FSsection.c b/src/H5FSsection.c
index 26ff7b9..9bdd99a 100644
--- a/src/H5FSsection.c
+++ b/src/H5FSsection.c
@@ -939,7 +939,8 @@ static herr_t
H5FS_sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls,
H5FS_section_info_t *sect)
{
- H5FS_node_t *fspace_node = NULL; /* Pointer to free space node of the correct size */
+ H5FS_node_t *fspace_node = NULL; /* Pointer to free space node of the correct size */
+ hbool_t fspace_node_alloc = FALSE; /* Whether the free space node was allocated */
unsigned bin; /* Bin to put the free space section in */
herr_t ret_value = SUCCEED; /* Return value */
@@ -971,6 +972,7 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, s
/* Allocate new free list size node */
if(NULL == (fspace_node = H5FL_MALLOC(H5FS_node_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for free space node")
+ fspace_node_alloc = TRUE;
/* Initialize the free list size node */
fspace_node->sect_size = sect->size;
@@ -981,6 +983,7 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, s
/* Insert new free space size node into bin's list */
if(H5SL_insert(sinfo->bins[bin].bin_list, fspace_node, &fspace_node->sect_size) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into skip list")
+ fspace_node_alloc = FALSE; /* (owned by the bin skip list now, don't need to free on error) */
/* Increment number of section sizes */
sinfo->tot_size_count++;
@@ -1016,6 +1019,13 @@ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bi
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into skip list")
done:
+ if(ret_value < 0)
+ if(fspace_node && fspace_node_alloc) {
+ if(fspace_node->sect_list && H5SL_close(fspace_node->sect_list) < 0)
+ HDONE_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy size free space node's skip list")
+ fspace_node = H5FL_FREE(H5FS_node_t, fspace_node);
+ } /* end if */
+
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_link_size() */