diff options
Diffstat (limited to 'src/H5Oattr.c')
-rw-r--r-- | src/H5Oattr.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 9cbcdc4..064c4cb 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -128,6 +128,9 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned H5_ATTR_UNUSED H5A_t *attr = NULL; H5S_extent_t *extent; /*extent dimensionality information */ size_t name_len; /*attribute name length */ + size_t dt_size; /* Datatype size */ + hssize_t sds_size; /* Signed Dataspace size */ + hsize_t ds_size; /* Dataspace size */ unsigned flags = 0; /* Attribute flags */ H5A_t *ret_value = NULL; /* Return value */ @@ -199,7 +202,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned H5_ATTR_UNUSED /* Decode attribute's dataspace extent */ if((extent = (H5S_extent_t *)(H5O_MSG_SDSPACE->decode)(f, dxpl_id, open_oh, - ((flags & H5O_ATTR_FLAG_SPACE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, p)) == NULL) + ((flags & H5O_ATTR_FLAG_SPACE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, p)) == NULL) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace") /* Copy the extent information to the dataspace */ @@ -217,8 +220,19 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned H5_ATTR_UNUSED else p += attr->shared->ds_size; + /* Get the datatype's size */ + if(0 == (dt_size = H5T_get_size(attr->shared->dt))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get datatype size") + + /* Get the datatype & dataspace sizes */ + if(0 == (dt_size = H5T_get_size(attr->shared->dt))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get datatype size") + if((sds_size = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get dataspace size") + ds_size = (hsize_t)sds_size; + /* Compute the size of the data */ - H5_CHECKED_ASSIGN(attr->shared->data_size, size_t, H5S_GET_EXTENT_NPOINTS(attr->shared->ds) * H5T_get_size(attr->shared->dt), hsize_t); + H5_CHECKED_ASSIGN(attr->shared->data_size, size_t, ds_size * (hsize_t)dt_size, hsize_t); /* Go get the data */ if(attr->shared->data_size) { |