summaryrefslogtreecommitdiffstats
path: root/src/H5Rint.c
diff options
context:
space:
mode:
authorvchoi <vchoi@jelly.ad.hdfgroup.org>2020-03-12 22:20:23 (GMT)
committervchoi <vchoi@jelly.ad.hdfgroup.org>2020-03-12 22:23:53 (GMT)
commitf33bb733be2da42672b4b0264cd4c6318ba35e9a (patch)
tree6a5c914680e21de41a1e2506957d1d4db214be92 /src/H5Rint.c
parent25a67c538c8014db867cba386c959fb9e7b714e8 (diff)
downloadhdf5-f33bb733be2da42672b4b0264cd4c6318ba35e9a.zip
hdf5-f33bb733be2da42672b4b0264cd4c6318ba35e9a.tar.gz
hdf5-f33bb733be2da42672b4b0264cd4c6318ba35e9a.tar.bz2
Fix issues when deserializing point/all/none selection with version beyond the library's supported version:
(1) Verify the decoded version before proceeding further with deserialization (2) Close the dataspace if errors occurred after opening the dataspace
Diffstat (limited to 'src/H5Rint.c')
-rw-r--r--src/H5Rint.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/H5Rint.c b/src/H5Rint.c
index 159bcca..4334faa 100644
--- a/src/H5Rint.c
+++ b/src/H5Rint.c
@@ -539,7 +539,8 @@ H5R__get_region(H5F_t *file, const void *_ref)
const uint8_t *p; /* Pointer to OID to store */
H5HG_t hobjid; /* Heap object ID */
uint8_t *buf = NULL; /* Buffer to store serialized selection in */
- H5S_t *ret_value; /* Return value */
+ H5S_t *ds = NULL; /* Temporary pointer to dataspace */
+ H5S_t *ret_value = NULL; /* Return value */
FUNC_ENTER_PACKAGE
@@ -564,18 +565,25 @@ H5R__get_region(H5F_t *file, const void *_ref)
H5F_addr_decode(oloc.file, &p, &(oloc.addr));
/* Open and copy the dataset's dataspace */
- if(NULL == (ret_value = H5S_read(&oloc)))
+ if(NULL == (ds = H5S_read(&oloc)))
HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, NULL, "not found")
/* Unserialize the selection */
- if(H5S_SELECT_DESERIALIZE(&ret_value, &p) < 0)
+ if(H5S_SELECT_DESERIALIZE(&ds, &p) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't deserialize selection")
+ ret_value = ds;
+
done:
/* Free the buffer allocated in H5HG_read() */
if(buf)
H5MM_xfree(buf);
+ if(ret_value == NULL) {
+ if(ds && H5S_close(ds) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace")
+ }
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5R__get_region() */