mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-04-18 17:40:55 +08:00
[svn-r4693] Purpose:
Bug Fix Description: The code in H5Sselect_hyperslab_valid contained an fencepost error and is allowing selections which overlap the extent by exactly one element in any dimension to pass as valid instead of flagging the selection as invalid. This bug only affects hyperslabs which have been OR'ed together, not the selection from a single H5Sselect_hyperslab. This fixes bug #550. Solution: Changed an '>' to an '>=' and added new regression test to check for error. Platforms tested: FreeBSD 4.4 (sleipnir)
This commit is contained in:
parent
43c1f21316
commit
3baaa562ee
@ -90,6 +90,9 @@ Library
|
||||
properly if they caused close() to fail.
|
||||
* Fixed a bug in internal B-tree code where a B-tree was not being copied
|
||||
correctly.
|
||||
* Fixed an off-by-one error in H5Sselect_valid when hyperslab selections
|
||||
which would allow hyperslab selections which overlapped the edge of the
|
||||
selection by one element as valid.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
@ -4994,9 +4994,9 @@ H5S_hyper_select_valid_helper (const H5S_hyper_span_info_t *spans, const hssize_
|
||||
while(curr!=NULL && ret_value==TRUE) {
|
||||
/* Check if an offset has been defined */
|
||||
/* Bounds check the selected point + offset against the extent */
|
||||
if(((curr->low+offset[rank])>(hssize_t)size[rank])
|
||||
if(((curr->low+offset[rank])>=(hssize_t)size[rank])
|
||||
|| ((curr->low+offset[rank])<0)
|
||||
|| ((curr->high+offset[rank])>(hssize_t)size[rank])
|
||||
|| ((curr->high+offset[rank])>=(hssize_t)size[rank])
|
||||
|| ((curr->high+offset[rank])<0)) {
|
||||
ret_value=FALSE;
|
||||
break;
|
||||
|
@ -3701,6 +3701,101 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist)
|
||||
free (data_out);
|
||||
} /* test_select_hyper_chunk() */
|
||||
|
||||
/****************************************************************
|
||||
**
|
||||
** test_select_valid(): Test basic H5S (dataspace) selection code.
|
||||
** Tests selection validity
|
||||
**
|
||||
****************************************************************/
|
||||
static void
|
||||
test_select_valid(void)
|
||||
{
|
||||
herr_t error;
|
||||
htri_t valid;
|
||||
hid_t main_space, sub_space;
|
||||
hssize_t safe_start[2]={1,1};
|
||||
hsize_t safe_count[2]={1,1};
|
||||
hssize_t start[2];
|
||||
hsize_t dims[2],maxdims[2],size[2],count[2];
|
||||
|
||||
/* Output message about test being performed */
|
||||
MESSAGE(5, ("Testing Selection Validity\n"));
|
||||
|
||||
count[0] = count[1] = 1;
|
||||
dims[0] = dims[1] = maxdims[0] = maxdims[1] = 10;
|
||||
|
||||
main_space = H5Screate_simple(2,dims,maxdims);
|
||||
CHECK(main_space, FAIL, "H5Screate_simple");
|
||||
|
||||
MESSAGE(8, ( "Case 1 : in the dimensions\nTry offset (4,4) and size(6,6), the original space is of size (10,10)\n"));
|
||||
start[0] = start[1] = 4;
|
||||
size[0] = size[1] = 6;
|
||||
|
||||
sub_space = H5Scopy(main_space);
|
||||
CHECK(sub_space, FAIL, "H5Scopy");
|
||||
|
||||
error=H5Sselect_hyperslab(sub_space,H5S_SELECT_SET,start,size,count,size);
|
||||
CHECK(error, FAIL, "H5Sselect_hyperslab");
|
||||
|
||||
valid=H5Sselect_valid(sub_space);
|
||||
VERIFY(valid, TRUE, "H5Sselect_valid");
|
||||
|
||||
error=H5Sselect_hyperslab(sub_space,H5S_SELECT_OR,safe_start,NULL,safe_count,NULL);
|
||||
CHECK(error, FAIL, "H5Sselect_hyperslab");
|
||||
|
||||
valid=H5Sselect_valid(sub_space);
|
||||
VERIFY(valid, TRUE, "H5Sselect_valid");
|
||||
|
||||
error=H5Sclose(sub_space);
|
||||
CHECK(error, FAIL, "H5Sclose");
|
||||
|
||||
MESSAGE(8, ( "Case 2 : exceed dimensions by 1\nTry offset (5,5) and size(6,6), the original space is of size (10,10)\n"));
|
||||
start[0] = start[1] = 5;
|
||||
size[0] = size[1] = 6;
|
||||
|
||||
sub_space = H5Scopy(main_space);
|
||||
CHECK(sub_space, FAIL, "H5Scopy");
|
||||
|
||||
error=H5Sselect_hyperslab(sub_space,H5S_SELECT_SET,start,size,count,size);
|
||||
CHECK(error, FAIL, "H5Sselect_hyperslab");
|
||||
|
||||
valid=H5Sselect_valid(sub_space);
|
||||
VERIFY(valid, FALSE, "H5Sselect_valid");
|
||||
|
||||
error=H5Sselect_hyperslab(sub_space,H5S_SELECT_OR,safe_start,NULL,safe_count,NULL);
|
||||
CHECK(error, FAIL, "H5Sselect_hyperslab");
|
||||
|
||||
valid=H5Sselect_valid(sub_space);
|
||||
VERIFY(valid, FALSE, "H5Sselect_valid");
|
||||
|
||||
error=H5Sclose(sub_space);
|
||||
CHECK(error, FAIL, "H5Sclose");
|
||||
|
||||
MESSAGE(8, ( "Case 3 : exceed dimensions by 2\nTry offset (6,6) and size(6,6), the original space is of size (10,10)\n"));
|
||||
start[0] = start[1] = 6;
|
||||
size[0] = size[1] = 6;
|
||||
|
||||
sub_space = H5Scopy(main_space);
|
||||
CHECK(sub_space, FAIL, "H5Scopy");
|
||||
|
||||
error=H5Sselect_hyperslab(sub_space,H5S_SELECT_SET,start,size,count,size);
|
||||
CHECK(error, FAIL, "H5Sselect_hyperslab");
|
||||
|
||||
valid=H5Sselect_valid(sub_space);
|
||||
VERIFY(valid, FALSE, "H5Sselect_valid");
|
||||
|
||||
error=H5Sselect_hyperslab(sub_space,H5S_SELECT_OR,safe_start,NULL,safe_count,NULL);
|
||||
CHECK(error, FAIL, "H5Sselect_hyperslab");
|
||||
|
||||
valid=H5Sselect_valid(sub_space);
|
||||
VERIFY(valid, FALSE, "H5Sselect_valid");
|
||||
|
||||
error=H5Sclose(sub_space);
|
||||
CHECK(error, FAIL, "H5Sclose");
|
||||
error=H5Sclose(main_space);
|
||||
CHECK(error, FAIL, "H5Sclose");
|
||||
} /* test_select_hyper_chunk() */
|
||||
|
||||
/****************************************************************
|
||||
**
|
||||
** test_select(): Main H5S selection testing routine.
|
||||
@ -3795,6 +3890,8 @@ test_select(void)
|
||||
ret=H5Pclose(plist_id);
|
||||
CHECK(ret, FAIL, "H5Pclose");
|
||||
|
||||
/* More tests for checking validity of selections */
|
||||
test_select_valid();
|
||||
} /* test_select() */
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user