mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-12 15:45:21 +08:00
Coverity: 1198196
This commit is contained in:
parent
6c071be031
commit
a28b123ca4
27
oc2/ocuri.c
27
oc2/ocuri.c
@ -594,10 +594,10 @@ suceeded, 0 otherwise; */
|
||||
int
|
||||
ocuridecodeparams(OCURI* ocuri)
|
||||
{
|
||||
char* cp;
|
||||
char* cp = NULL;
|
||||
int i,c;
|
||||
int nparams;
|
||||
char* params;
|
||||
char* params = NULL;
|
||||
char** plist;
|
||||
|
||||
if(ocuri == NULL) return 0;
|
||||
@ -615,21 +615,23 @@ ocuridecodeparams(OCURI* ocuri)
|
||||
|
||||
/* plist is an env style list */
|
||||
plist = (char**)calloc(1,sizeof(char*)*(2*nparams+1)); /* +1 for null termination */
|
||||
if(plist == NULL)
|
||||
return 0;
|
||||
if(plist == NULL) {
|
||||
free(params);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Break up each param into a (name,value) pair*/
|
||||
/* and insert into the param list */
|
||||
/* parameters of the form name name= are converted to name=""*/
|
||||
for(cp=params,i=0;i<nparams;i++) {
|
||||
char* next = cp+strlen(cp)+1; /* save ptr to next pair*/
|
||||
char* vp;
|
||||
/*break up the ith param*/
|
||||
vp = strchr(cp,'=');
|
||||
if(vp != NULL) {*vp = EOFCHAR; vp++;} else {vp = "";}
|
||||
plist[2*i] = nulldup(cp);
|
||||
plist[2*i+1] = nulldup(vp);
|
||||
cp = next;
|
||||
char* next = cp+strlen(cp)+1; /* save ptr to next pair*/
|
||||
char* vp;
|
||||
/*break up the ith param*/
|
||||
vp = strchr(cp,'=');
|
||||
if(vp != NULL) {*vp = EOFCHAR; vp++;} else {vp = "";}
|
||||
plist[2*i] = nulldup(cp);
|
||||
plist[2*i+1] = nulldup(vp);
|
||||
cp = next;
|
||||
}
|
||||
plist[2*nparams] = NULL;
|
||||
free(params);
|
||||
@ -847,4 +849,3 @@ ocuridecodeonly(char* s, char* only)
|
||||
*outptr = EOFCHAR;
|
||||
return decoded;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user