put_vars checking for NULL start for non-scalar vars and test

This commit is contained in:
Ed Hartnett 2018-08-13 13:05:32 -06:00
parent 8b26c83379
commit 97c2541a37
2 changed files with 14 additions and 0 deletions

View File

@ -554,9 +554,18 @@ NC_put_vars(int ncid, int varid, const size_t *start,
const void *value, nc_type memtype)
{
NC* ncp;
int varndims;
int status;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* Only scalar vars may have null starts. */
if(start == NULL) {
status = nc_inq_varndims(ncid, varid, &varndims);
if(status != NC_NOERR) return status;
if (varndims > 0) return NC_EINVALCOORDS;
}
return ncp->dispatch->put_vars(ncid,varid,start,edges,stride,value,memtype);
}

View File

@ -56,6 +56,11 @@ main()
if ((retval = nc_enddef(ncid)))
ERR(retval);
/* This will fail. */
if ((retval = nc_put_vars_float(ncid, varid, NULL, count, stride,
mydata)) != NC_EINVALCOORDS)
ERR(99);
/* write data */
if ((retval = nc_put_vars_float(ncid, varid, start, count, stride, mydata)))
ERR(retval);