diff options
author | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2012-09-09 19:08:12 (GMT) |
---|---|---|
committer | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2012-09-09 19:08:12 (GMT) |
commit | 2fae4fbfa629c1bfbeeb31d6b6a403528f1426d9 (patch) | |
tree | f2506f983bf829449e7782785869f799f52cd11d | |
parent | 0824b43ecdde50e93e0e59f1080234d582a63b72 (diff) | |
download | hdf5-2fae4fbfa629c1bfbeeb31d6b6a403528f1426d9.zip hdf5-2fae4fbfa629c1bfbeeb31d6b6a403528f1426d9.tar.gz hdf5-2fae4fbfa629c1bfbeeb31d6b6a403528f1426d9.tar.bz2 |
[svn-r22746] Description:
Fix for HDFFV-7959 H5Rdereference should check for default (HADDR_UNDEF) value and not continue processing and return so that ret value can be checked and handled properly.
Added fix and test, reviewed:
Tested: jam (gnu, intel)
-rw-r--r-- | src/H5R.c | 4 | ||||
-rw-r--r-- | test/trefer.c | 5 |
2 files changed, 9 insertions, 0 deletions
@@ -568,6 +568,7 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r { H5G_loc_t loc; /* Group location */ H5F_t *file = NULL; /* File object */ + haddr_t addr; hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -582,6 +583,9 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + addr = *((const haddr_t*)_ref); + if(!H5F_addr_defined(addr)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer") /* Get the file pointer from the entry */ file = loc.oloc->file; diff --git a/test/trefer.c b/test/trefer.c index 53f7b92..848e060 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -1069,6 +1069,7 @@ test_reference_obj_deleted(void) hid_t sid1; /* Dataspace ID */ hobj_ref_t oref; /* Object Reference to test */ H5O_type_t obj_type; /* Object type */ + haddr_t addr = HADDR_UNDEF; /* test for undefined reference */ herr_t ret; /* Generic return value */ /* Create file */ @@ -1126,6 +1127,10 @@ test_reference_obj_deleted(void) dataset = H5Dopen2(fid1, "/Dataset2", H5P_DEFAULT); CHECK(ret, FAIL, "H5Dopen2"); + /* Open undefined reference */ + dset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &addr); + VERIFY(dset2, FAIL, "H5Rdereference2"); + /* Read selection from disk */ HDmemset(&oref, 0, sizeof(hobj_ref_t)); ret = H5Dread(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &oref); |