summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeil Fortner <fortnern@gmail.com>2022-12-08 16:30:29 (GMT)
committerGitHub <noreply@github.com>2022-12-08 16:30:29 (GMT)
commitef4f1f2bd41a5812cdb79b5a829d37bb56e37a4d (patch)
treeee25dbc545b8a9371f6aabeb36c96c05b6e4fa34 /src
parent0b4e9cf976438f0a6df7719518d1b1bb96c2caca (diff)
downloadhdf5-ef4f1f2bd41a5812cdb79b5a829d37bb56e37a4d.zip
hdf5-ef4f1f2bd41a5812cdb79b5a829d37bb56e37a4d.tar.gz
hdf5-ef4f1f2bd41a5812cdb79b5a829d37bb56e37a4d.tar.bz2
Check for size==0 for all datatypes read from disk, not just compound (#2287)
members
Diffstat (limited to 'src')
-rw-r--r--src/H5Odtype.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index fd211af..e5e8996 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -148,6 +148,10 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t
/* Size */
UINT32DECODE(*pp, dt->shared->size);
+ /* Check for invalid datatype size */
+ if (dt->shared->size == 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "invalid datatype size")
+
switch (dt->shared->type) {
case H5T_INTEGER:
/*
@@ -344,15 +348,7 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t
HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't release datatype info")
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type")
} /* end if */
-
- /* Check for invalid member size */
- if (temp_type->shared->size == 0) {
- dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name =
- H5MM_xfree(dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name);
- if (H5T_close_real(temp_type) < 0)
- HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't release datatype info")
- HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "invalid field size in member type")
- }
+ HDassert(temp_type->shared->size > 0);
/* Upgrade the version if we can and it is necessary */
if (can_upgrade && temp_type->shared->version > version) {