diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2011-04-15 19:06:38 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2011-04-15 19:06:38 (GMT) |
commit | 427add7c92172ee24e71dcc4e780b8d9d144fbe6 (patch) | |
tree | 09d7f6a6f6b120185ca5e934e78886a2c78212e3 /src | |
parent | 39deb10f4a086fdabd4a297f19f10e5acdc3fd21 (diff) | |
download | hdf5-427add7c92172ee24e71dcc4e780b8d9d144fbe6.zip hdf5-427add7c92172ee24e71dcc4e780b8d9d144fbe6.tar.gz hdf5-427add7c92172ee24e71dcc4e780b8d9d144fbe6.tar.bz2 |
[svn-r20513] Description:
Correct several problems with compound datatypes that don't have any
fields added:
- Change assertion to error report when a file is encountered which has this
situation.
- Added check to attribute creation to avoid creating attributes with a
datatype like this (datasets and named datatypes already have the check)
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Diffstat (limited to 'src')
-rw-r--r-- | src/H5A.c | 10 | ||||
-rw-r--r-- | src/H5Odtype.c | 5 |
2 files changed, 10 insertions, 5 deletions
@@ -389,14 +389,18 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, /* Check if the dataspace has an extent set (or is NULL) */ if(!(H5S_has_extent(space))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace extent has not been set") + HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "dataspace extent has not been set") + + /* Check if the datatype is "sensible" for use in a dataset */ + if(H5T_is_sensible(type) != TRUE) + HGOTO_ERROR(H5E_ATTR, H5E_BADTYPE, FAIL, "datatype is not sensible") /* Build the attribute information */ if(NULL == (attr = H5FL_CALLOC(H5A_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for attribute info") + HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed for attribute info") if(NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t))) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate shared attr structure") + HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "can't allocate shared attr structure") /* If the creation property list is H5P_DEFAULT, use the default character encoding */ if(acpl_id == H5P_DEFAULT) diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 51694a3..f419e44 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -268,12 +268,13 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p * Compound datatypes... */ dt->shared->u.compnd.nmembs = flags & 0xffff; - HDassert(dt->shared->u.compnd.nmembs > 0); + if(dt->shared->u.compnd.nmembs == 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid number of members: %u", dt->shared->u.compnd.nmembs) dt->shared->u.compnd.nalloc = dt->shared->u.compnd.nmembs; dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_calloc(dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)); dt->shared->u.compnd.memb_size = 0; if(NULL == dt->shared->u.compnd.memb) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { unsigned ndims = 0; /* Number of dimensions of the array field */ htri_t can_upgrade; /* Whether we can upgrade this type's version */ |