mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
move ncid check to the first and add varid check before name check
This commit is contained in:
parent
df91c19f3c
commit
fbbed1f9ff
@ -441,6 +441,7 @@ NCP_get_att(
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
status = NCP_inq_att(ncid,varid,name,&xtype,NULL);
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
if(memtype == NC_NAT) memtype = xtype;
|
||||
|
||||
@ -487,6 +488,14 @@ NCP_put_att(
|
||||
int status;
|
||||
MPI_Offset mpilen;
|
||||
|
||||
/* check if ncid is valid */
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
/* check if varid is valid */
|
||||
status = ncmpi_inq_varnatts(nc->int_ncid, varid, NULL);
|
||||
if (status != NC_NOERR) return status;
|
||||
|
||||
if (!name || (strlen(name) > NC_MAX_NAME))
|
||||
return NC_EBADNAME;
|
||||
|
||||
@ -495,9 +504,6 @@ NCP_put_att(
|
||||
if(((unsigned long) len) > X_INT_MAX)
|
||||
return NC_EINVAL;
|
||||
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
mpilen = len;
|
||||
|
||||
switch (memtype) {
|
||||
|
Loading…
Reference in New Issue
Block a user