mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
More pedantically correct check
This modifies the previous change to be more pedantically correct. It should always be an NC_EINVALCOORDS error if start exceeds fdims[2]; however, if start equals fdims[2], then it is only an error if count is non-zero.
This commit is contained in:
parent
9290b31c9d
commit
c7ccdfa543
@ -625,7 +625,8 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
||||
assert(dim && dim->dimid == var->dimids[d2]);
|
||||
if (!dim->unlimited)
|
||||
{
|
||||
if (start[d2] >= (hssize_t)fdims[d2] && count[d2] > 0)
|
||||
if (start[d2] > (hssize_t)fdims[d2] ||
|
||||
(start[d2] == (hssize_t)fdims[d2] && count[d2] > 0))
|
||||
BAIL_QUIET(NC_EINVALCOORDS);
|
||||
if (start[d2] + count[d2] > fdims[d2])
|
||||
BAIL_QUIET(NC_EEDGE);
|
||||
@ -956,7 +957,8 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
||||
BAIL(retval);
|
||||
|
||||
/* Check for out of bound requests. */
|
||||
if (start[d2] >= (hssize_t)ulen && count[d2])
|
||||
if (start[d2] > (hssize_t)ulen ||
|
||||
(start[d2] == (hssize_t)ulen && count[d2] > 0))
|
||||
BAIL_QUIET(NC_EINVALCOORDS);
|
||||
if (start[d2] + count[d2] > ulen)
|
||||
BAIL_QUIET(NC_EEDGE);
|
||||
@ -979,7 +981,8 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
||||
else
|
||||
{
|
||||
/* Check for out of bound requests. */
|
||||
if (start[d2] >= (hssize_t)fdims[d2] && count[d2] > 0)
|
||||
if (start[d2] > (hssize_t)fdims[d2] ||
|
||||
(start[d2] == (hssize_t)fdims[d2] && count[d2] > 0))
|
||||
BAIL_QUIET(NC_EINVALCOORDS);
|
||||
if (start[d2] + count[d2] > fdims[d2])
|
||||
BAIL_QUIET(NC_EEDGE);
|
||||
|
Loading…
Reference in New Issue
Block a user