summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5A.c4
-rw-r--r--src/H5D.c6
-rw-r--r--src/H5Dio.c16
-rw-r--r--src/H5S.c32
-rw-r--r--src/H5Sprivate.h1
5 files changed, 59 insertions, 0 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 21c3390..872d3fe 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -224,6 +224,10 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type,
assert(type);
assert(space);
+ /* 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")
+
/* Build the attribute information */
if((attr = H5MM_calloc(sizeof(H5A_t)))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for attribute info")
diff --git a/src/H5D.c b/src/H5D.c
index cf761c7..177e3e1 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -2135,6 +2135,10 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
if(H5T_detect_class(type, H5T_VLEN))
has_vl_type=TRUE;
+ /* Check if the dataspace has an extent set (or is NULL) */
+ if( !(H5S_has_extent(space)) )
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "dataspace extent has not been set.")
+
/* Initialize the dataset object */
if(NULL == (new_dset = H5D_new(dcpl_id,TRUE,has_vl_type)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
@@ -3559,6 +3563,8 @@ H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype")
if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace")
+ if( !(H5S_has_extent(space)) )
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set")
ret_value=H5S_select_iterate(buf,type_id,space,op,operator_data);
diff --git a/src/H5Dio.c b/src/H5Dio.c
index a480209..9fb860e 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -224,6 +224,10 @@ H5D_fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_t
assert(buf_type);
assert(space);
+ /* Make sure 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")
+
/* Get the memory and file datatype sizes */
src_type_size = H5T_get_size(fill_type);
dst_type_size = H5T_get_size(buf_type);
@@ -683,6 +687,12 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
if (nelmts!=(hsize_t)H5S_GET_SELECT_NPOINTS(file_space))
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes")
+ /* Make sure that both selections have their extents set */
+ if( !(H5S_has_extent(file_space)) )
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set")
+ if( !(H5S_has_extent(mem_space)) )
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set")
+
/* Retrieve dataset properties */
/* <none needed in the general case> */
@@ -933,6 +943,12 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
if (nelmts!=(hsize_t)H5S_GET_SELECT_NPOINTS(file_space))
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes")
+ /* Make sure that both selections have their extents set */
+ if( !(H5S_has_extent(file_space)) )
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set")
+ if( !(H5S_has_extent(mem_space)) )
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set")
+
/* Retrieve dataset properties */
/* <none needed currently> */
diff --git a/src/H5S.c b/src/H5S.c
index 86ac23a..1993966 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -2167,6 +2167,38 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
}
+/*-------------------------------------------------------------------------
+ * Function: H5S_has_extent
+ *
+ * Purpose: Determines if a simple dataspace's extent has been set (e.g.,
+ * by H5Sset_extent_simple() ). Helps avoid write errors.
+ *
+ * Return: TRUE if dataspace has extent set
+ * FALSE if dataspace's extent is uninitialized
+ *
+ * Programmer: James Laird
+ *
+ * Date: July 23, 2004
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5S_has_extent(const H5S_t *ds)
+{
+ htri_t ret_value;
+ FUNC_ENTER_NOAPI(H5S_has_extent, FAIL)
+
+ assert(ds);
+
+ if(ds->extent.rank==0 && ds->extent.nelem == 0 && ds->extent.type != H5S_NULL)
+ ret_value = FALSE;
+ else
+ ret_value = TRUE;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+}
+
/*-------------------------------------------------------------------------
* Function: H5S_set_extent_real
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index 195a172..be8108e 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -216,6 +216,7 @@ H5_DLL hsize_t H5S_get_npoints_max(const H5S_t *ds);
H5_DLL int H5S_get_simple_extent_ndims(const H5S_t *ds);
H5_DLL int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[]/*out*/,
hsize_t max_dims[]/*out*/);
+H5_DLL hbool_t H5S_has_extent(const H5S_t *ds);
H5_DLL herr_t H5S_modify(struct H5G_entry_t *ent, const H5S_t *space,
hbool_t update_time, hid_t dxpl_id);
H5_DLL herr_t H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, const H5S_t *ds);