summaryrefslogtreecommitdiffstats
path: root/src/H5Edeprec.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-01-23 07:00:00 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-01-23 07:00:00 (GMT)
commitbb25c85e794449d3bf59d8811e53288569161790 (patch)
treee6c37cf6f8bba9323540ddddb70300b43351d88f /src/H5Edeprec.c
parentfcc03a356b4dd5e58cc88b692b3d05d75b8ae5d0 (diff)
downloadhdf5-bb25c85e794449d3bf59d8811e53288569161790.zip
hdf5-bb25c85e794449d3bf59d8811e53288569161790.tar.gz
hdf5-bb25c85e794449d3bf59d8811e53288569161790.tar.bz2
[svn-r18159] Description:
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/H5Edeprec.c')
-rw-r--r--src/H5Edeprec.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c
index 0997f3c..30f3ae9 100644
--- a/src/H5Edeprec.c
+++ b/src/H5Edeprec.c
@@ -122,10 +122,10 @@ char *
H5Eget_major(H5E_major_t maj)
{
H5E_msg_t *msg; /* Pointer to error message */
- ssize_t size = 0; /* Return value */
+ ssize_t size;
H5E_type_t type;
- char *msg_str;
- char *ret_value = NULL;
+ char *msg_str = NULL;
+ char *ret_value; /* Return value */
FUNC_ENTER_API_NOCLEAR(H5Eget_major, NULL)
@@ -133,22 +133,26 @@ H5Eget_major(H5E_major_t maj)
if(NULL == (msg = (H5E_msg_t *)H5I_object_verify(maj, H5I_ERROR_MSG)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID")
- /* Get the message's text */
+ /* Get the size & type of the message's text */
if((size = H5E_get_msg(msg, &type, NULL, (size_t)0)) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text")
-
if(type != H5E_MAJOR)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a major one")
- /* Don't know who is going to free it */
- msg_str = (char *)H5MM_malloc((size_t)(++size) * sizeof(char));
+ /* Application will free this */
+ size++;
+ msg_str = (char *)H5MM_malloc((size_t)size);
+ /* Get the text for the message */
if(H5E_get_msg(msg, NULL, msg_str, (size_t)size) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text")
ret_value = msg_str;
done:
+ if(!ret_value)
+ msg_str = (char *)H5MM_xfree(msg_str);
+
FUNC_LEAVE_API(ret_value)
} /* end H5Eget_major() */
@@ -170,10 +174,10 @@ char *
H5Eget_minor(H5E_minor_t min)
{
H5E_msg_t *msg; /* Pointer to error message */
- ssize_t size = 0; /* Return value */
+ ssize_t size;
H5E_type_t type;
- char *msg_str;
- char *ret_value = NULL;
+ char *msg_str = NULL;
+ char *ret_value; /* Return value */
FUNC_ENTER_API_NOCLEAR(H5Eget_minor, NULL)
@@ -181,22 +185,26 @@ H5Eget_minor(H5E_minor_t min)
if(NULL == (msg = (H5E_msg_t *)H5I_object_verify(min, H5I_ERROR_MSG)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID")
- /* Get the message's text */
+ /* Get the size & type of the message's text */
if((size = H5E_get_msg(msg, &type, NULL, (size_t)0)) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text")
-
if(type != H5E_MINOR)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a minor one")
- /* Don't know who is going to free it */
- msg_str = (char *)H5MM_malloc((size_t)(++size) * sizeof(char));
+ /* Application will free this */
+ size++;
+ msg_str = (char *)H5MM_malloc((size_t)size);
+ /* Get the text for the message */
if(H5E_get_msg(msg, NULL, msg_str, (size_t)size) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text")
ret_value = msg_str;
done:
+ if(!ret_value)
+ msg_str = (char *)H5MM_xfree(msg_str);
+
FUNC_LEAVE_API(ret_value)
} /* end H5Eget_minor() */