[svn-r10216]

Purpose:
Bug fix

Description:
Calling H5Iobject_verify on an invalid type of ID (e.g., H5I_BADID) triggers
an assert.

Solution:
Test for this condition and return an error instead of an assert.
Added tests for this case.

Platforms tested:
sleipnir (minor change)
This commit is contained in:
James Laird 2005-03-14 18:02:21 -05:00
parent fbcc3e84c0
commit d1d9335d7a
2 changed files with 41 additions and 11 deletions

View File

@ -957,7 +957,7 @@ done:
* Failure: NULL
*
* Programmer: Nathaniel Furrer
* James Laird
* James Laird
* Friday, April 23, 2004
*
* Modifications:
@ -966,19 +966,24 @@ done:
*/
void *H5Iobject_verify(hid_t id, H5I_type_t id_type)
{
void * ret_value; /* Return value */
void * ret_value; /* Return value */
FUNC_ENTER_API(H5Iobject_verify, NULL);
FUNC_ENTER_API(H5Iobject_verify, NULL);
if( H5I_IS_LIB_TYPE( id_type ) )
{
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type");
}
if( H5I_IS_LIB_TYPE( id_type ) )
{
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type");
}
ret_value = H5I_object_verify(id, id_type);
if(id_type < 1 || id_type >= H5I_next_type)
{
HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "identifier has invalid type");
}
done:
FUNC_LEAVE_API(ret_value);
ret_value = H5I_object_verify(id, id_type);
done:
FUNC_LEAVE_API(ret_value);
}

View File

@ -22,7 +22,7 @@ static int id_test(void)
testObj = malloc(7 * sizeof(int));
/* Try to register an ID with ficticious type #420 */
/* Try to register an ID with ficticious types */
H5E_BEGIN_TRY
arrayID = H5Iregister((H5I_type_t) 420, testObj);
H5E_END_TRY
@ -31,6 +31,31 @@ static int id_test(void)
if(arrayID != H5I_INVALID_HID)
goto out;
H5E_BEGIN_TRY
arrayID = H5Iregister((H5I_type_t) -1, testObj);
H5E_END_TRY
VERIFY(arrayID, H5I_INVALID_HID, "H5Iregister");
if(arrayID != H5I_INVALID_HID)
goto out;
/* Try to access IDs with ficticious types */
H5E_BEGIN_TRY
testObj = H5Iobject_verify(100, (H5I_type_t) 0);
H5E_END_TRY
VERIFY(arrayID, NULL, "H5Iobject_verify");
if(testObj != NULL)
goto out;
H5E_BEGIN_TRY
testObj = H5Iobject_verify(700, (H5I_type_t) 700);
H5E_END_TRY
VERIFY(arrayID, NULL, "H5Iobject_verify");
if(testObj != NULL)
goto out;
/* Register a type */
myType = H5Iregister_type(64, 0, (H5I_free_t) free );