@@ -453,7 +453,7 @@ namespace splash
453453 // dst buffer is allowed to be NULL
454454 // in this case, only the size of the dataset is returned
455455 // if the dataset is empty, return just its size as there is nothing to read
456- if ((dst != NULL ) && ( getNDims () > 0 ) )
456+ if (getNDims () > 0 )
457457 {
458458 log_msg (3 ,
459459 " \n ndims = %llu\n "
@@ -480,18 +480,23 @@ namespace splash
480480 if (dst_dataspace < 0 )
481481 throw DCException (getExceptionString (" read: Failed to create target dataspace" ));
482482
483- if (H5Sselect_hyperslab (dst_dataspace, H5S_SELECT_SET, dstOffset.getPointer (), NULL ,
484- srcSize.getPointer (), NULL ) < 0 ||
485- H5Sselect_valid (dst_dataspace) <= 0 )
486- throw DCException (getExceptionString (" read: Target dataspace hyperslab selection is not valid!" ));
487-
488- if (H5Sselect_hyperslab (dataspace, H5S_SELECT_SET, srcOffset.getPointer (), NULL ,
489- srcSize.getPointer (), NULL ) < 0 ||
490- H5Sselect_valid (dataspace) <= 0 )
491- throw DCException (getExceptionString (" read: Source dataspace hyperslab selection is not valid!" ));
483+ if (!dst) {
484+ H5Sselect_none (dst_dataspace);
485+ } else {
486+ if (H5Sselect_hyperslab (dst_dataspace, H5S_SELECT_SET, dstOffset.getPointer (), NULL ,
487+ srcSize.getPointer (), NULL ) < 0 ||
488+ H5Sselect_valid (dst_dataspace) <= 0 )
489+ throw DCException (getExceptionString (" read: Target dataspace hyperslab selection is not valid!" ));
490+ }
492491
493- if (srcSize.getScalarSize () == 0 )
492+ if (!dst || srcSize.getScalarSize () == 0 ) {
494493 H5Sselect_none (dataspace);
494+ } else {
495+ if (H5Sselect_hyperslab (dataspace, H5S_SELECT_SET, srcOffset.getPointer (), NULL ,
496+ srcSize.getPointer (), NULL ) < 0 ||
497+ H5Sselect_valid (dataspace) <= 0 )
498+ throw DCException (getExceptionString (" read: Source dataspace hyperslab selection is not valid!" ));
499+ }
495500
496501 if (H5Dread (dataset, this ->datatype , dst_dataspace, dataspace, dsetReadProperties, dst) < 0 )
497502 throw DCException (getExceptionString (" read: Failed to read dataset" ));
0 commit comments