summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2024-03-05 14:23:34 (GMT)
committerGitHub <noreply@github.com>2024-03-05 14:23:34 (GMT)
commitf5f6975c2fc123a2c7f9d26cdbcda87d31ac4ea8 (patch)
tree23a7418ebec5ad433f57fa6cccdba7ee64e7f60a /src
parent60532b6c569efcf780e072824e5f9bda2d4b323e (diff)
downloadhdf5-f5f6975c2fc123a2c7f9d26cdbcda87d31ac4ea8.zip
hdf5-f5f6975c2fc123a2c7f9d26cdbcda87d31ac4ea8.tar.gz
hdf5-f5f6975c2fc123a2c7f9d26cdbcda87d31ac4ea8.tar.bz2
Fix issue where H5Tset_fields does not account for datatype offsets (#4061)
H5Tset_fields did not account for any offset in a floating-point datatype, causing it to fail when a datatype's precision is correctly set such that it doesn't include the offset bits.
Diffstat (limited to 'src')
-rw-r--r--src/H5Tfloat.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/H5Tfloat.c b/src/H5Tfloat.c
index 01a5607..9f7b4f7 100644
--- a/src/H5Tfloat.c
+++ b/src/H5Tfloat.c
@@ -106,11 +106,11 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, size_t mpos
dt = dt->shared->parent; /*defer to parent*/
if (H5T_FLOAT != dt->shared->type)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class");
- if (epos + esize > dt->shared->u.atomic.prec)
+ if (epos + esize - dt->shared->u.atomic.offset > dt->shared->u.atomic.prec)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent bit field size/location is invalid");
- if (mpos + msize > dt->shared->u.atomic.prec)
+ if (mpos + msize - dt->shared->u.atomic.offset > dt->shared->u.atomic.prec)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mantissa bit field size/location is invalid");
- if (spos >= dt->shared->u.atomic.prec)
+ if (spos - dt->shared->u.atomic.offset >= dt->shared->u.atomic.prec)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign location is not valid");
/* Check for overlap */