From 53c6f67778c3dc5b0e39276227c77eba93ab92f0 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 11 Mar 2008 17:21:37 -0500 Subject: [svn-r14720] Description: Minor bug fix to H5Aget_num_attrs() to return error when an invalid location ID is passed in. Tested on: Mac OS X/32 (amazon) Too minor to require h5committest --- src/H5Adeprec.c | 2 ++ test/tattr.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 9f888c8..85cef2f 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -312,6 +312,8 @@ H5Aget_num_attrs(hid_t loc_id) H5TRACE1("Is", "i", loc_id); /* check arguments */ + if(H5I_BADID == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad location ID") if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(NULL == (obj = H5I_object(loc_id))) diff --git a/test/tattr.c b/test/tattr.c index d448397..12350c3 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -3303,6 +3303,10 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) CHECK(dataset, FAIL, "H5Dopen2"); + /* Get number of attributes with bad ID */ + ret = H5Aget_num_attrs(-1); + VERIFY(ret, FAIL, "H5Aget_num_attrs"); + /* Get number of attributes */ ret = H5Aget_num_attrs(dataset); VERIFY(ret, 1, "H5Aget_num_attrs"); -- cgit v0.12