Coverity: 1198196

This commit is contained in:
Ward Fisher 2014-08-08 15:22:46 -06:00
parent 6c071be031
commit a28b123ca4

View File

@ -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;
}