summaryrefslogtreecommitdiffstats
path: root/src/H5D.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-06-11 16:03:04 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-06-11 16:03:04 (GMT)
commit33a1bc03c43c68a95b301d8315a15fa7775851e4 (patch)
tree0402f78abb06b3d8e7b728ebb0a2f64bdff64fb6 /src/H5D.c
parente4a300b04e0eb4f3c7cfb96b925d5cf9975c8188 (diff)
downloadhdf5-33a1bc03c43c68a95b301d8315a15fa7775851e4.zip
hdf5-33a1bc03c43c68a95b301d8315a15fa7775851e4.tar.gz
hdf5-33a1bc03c43c68a95b301d8315a15fa7775851e4.tar.bz2
[svn-r5586] Purpose:
Bug Fix Description: H5Dcreate and H5Tcommit allow "empty" compound and enumerated types (i.e. ones with no members) to be stored in the file, but this causes an assertion failure and is somewhat vapid. Solution: Check the datatype "makes sense" before using it for H5Dcreate and H5Tcommit. Platforms tested: FreeBSD 4.5 (sleipnir)
Diffstat (limited to 'src/H5D.c')
-rw-r--r--src/H5D.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 0ead927..ac63596 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1559,20 +1559,25 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type,
if(NULL == (new_dset = H5D_new(dcpl_id)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- /* Get new dataset's property list object */
- if (NULL == (new_plist = H5I_object(new_dset->dcpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list");
+ /* Check if the datatype is "sensible" for use in a dataset */
+ if(H5T_is_sensible(type)!=TRUE)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible");
- if(H5P_get(new_plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout");
-
/* Copy datatype for dataset */
- new_dset->type = H5T_copy(type, H5T_COPY_ALL);
+ if((new_dset->type = H5T_copy(type, H5T_COPY_ALL))==NULL)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy datatype");
/* Mark any VL datatypes as being on disk now */
if (H5T_vlen_mark(new_dset->type, f, H5T_VLEN_DISK)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location");
+ /* Get new dataset's property list object */
+ if (NULL == (new_plist = H5I_object(new_dset->dcpl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list");
+
+ if(H5P_get(new_plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout");
+
if(H5P_get(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve external file list");