diff options
Diffstat (limited to 'src/H5R.c')
-rw-r--r-- | src/H5R.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -411,6 +411,10 @@ done: 13 July 2011 I added the OAPL_ID parameter for the object being referenced. It only supports dataset access property list currently. + + M. Scot Breitenfeld + 3 March 2015 + Added a check for undefined reference pointer. --------------------------------------------------------------------------*/ hid_t H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, hbool_t app_ref) @@ -435,8 +439,10 @@ H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, switch(ref_type) { case H5R_OBJECT: oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */ - break; - + if(!H5F_addr_defined(oloc.addr) || oloc.addr == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer") + break; + case H5R_DATASET_REGION: { H5HG_t hobjid; /* Heap object ID */ @@ -448,6 +454,9 @@ H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); UINT32DECODE(p, hobjid.idx); + if(!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer") + /* Get the dataset region from the heap (allocate inside routine) */ if(NULL == (buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") |