diff --git a/src/H5D.c b/src/H5D.c index 75050407ba..1f0175951e 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -2250,6 +2250,11 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, assert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); + /* Initialize these before any errors can occur */ + HDmemset(&mem_iter,0,sizeof(H5S_sel_iter_t)); + HDmemset(&bkg_iter,0,sizeof(H5S_sel_iter_t)); + HDmemset(&file_iter,0,sizeof(H5S_sel_iter_t)); + /* Get the dataset's creation property list */ if (NULL == (dc_plist = H5I_object(dataset->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -2258,11 +2263,6 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, if (NULL == (dx_plist = H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); - /* Initialize these before any errors can occur */ - HDmemset(&mem_iter,0,sizeof(H5S_sel_iter_t)); - HDmemset(&bkg_iter,0,sizeof(H5S_sel_iter_t)); - HDmemset(&file_iter,0,sizeof(H5S_sel_iter_t)); - if (!file_space) { if (NULL==(free_this_space=H5S_read (&(dataset->ent)))) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data space from dataset header"); @@ -2664,6 +2664,11 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, assert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); + /* Initialize these before any errors can occur */ + HDmemset(&mem_iter,0,sizeof(H5S_sel_iter_t)); + HDmemset(&bkg_iter,0,sizeof(H5S_sel_iter_t)); + HDmemset(&file_iter,0,sizeof(H5S_sel_iter_t)); + /* Get the dataset's creation property list */ if (NULL == (dc_plist = H5I_object(dataset->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -2689,11 +2694,6 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Parallel IO does not support writing region reference datatypes yet"); #endif - /* Initialize these before any errors can occur */ - HDmemset(&mem_iter,0,sizeof(H5S_sel_iter_t)); - HDmemset(&bkg_iter,0,sizeof(H5S_sel_iter_t)); - HDmemset(&file_iter,0,sizeof(H5S_sel_iter_t)); - if (0==(H5F_get_intent(dataset->ent.file) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "no write intent on file");