mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
put_vars checking for NULL start for non-scalar vars and test
This commit is contained in:
parent
8b26c83379
commit
97c2541a37
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user