Corrected a couple of static analysis-detected warnings.

This commit is contained in:
Ward Fisher 2015-02-10 13:04:37 -07:00
parent b40068afdb
commit 473163c41a

View File

@ -222,6 +222,8 @@ ocset_flags_perlink(OCstate* state)
if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_USERPWD); if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_USERPWD);
if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_PROXY); if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_PROXY);
if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_USE_SSL); if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_USE_SSL);
if(stat != OC_NOERR)
return stat;
/* Following are always set */ /* Following are always set */
ocset_curlflag(state, CURLOPT_FOLLOWLOCATION); ocset_curlflag(state, CURLOPT_FOLLOWLOCATION);
@ -248,7 +250,10 @@ oc_set_curl_options(OCstate* state)
struct OCCURLFLAG* ocflag = NULL; struct OCCURLFLAG* ocflag = NULL;
hostport = occombinehostport(state->uri); hostport = occombinehostport(state->uri);
if(hostport == NULL) hostport = ""; if(hostport == NULL) {
hostport = (char*)malloc(sizeof(char)*1);
*hostport = "";
}
store = &ocglobalstate.rc.ocrc; store = &ocglobalstate.rc.ocrc;
triple = store->triples; triple = store->triples;
@ -256,7 +261,7 @@ oc_set_curl_options(OCstate* state)
/* Assume that the triple store has been properly sorted */ /* Assume that the triple store has been properly sorted */
for(i=0;i<store->ntriples;i++,triple++) { for(i=0;i<store->ntriples;i++,triple++) {
size_t hostlen = strlen(triple->host); size_t hostlen = strlen(triple->host);
const char* flagname; const char* flagname;
if(ocstrncmp("CURL.",triple->key,5) != 0) continue; /* not a curl flag */ if(ocstrncmp("CURL.",triple->key,5) != 0) continue; /* not a curl flag */
/* do hostport prefix comparison */ /* do hostport prefix comparison */
@ -270,7 +275,7 @@ oc_set_curl_options(OCstate* state)
stat = ocset_curlopt(state,ocflag->flag,cvt(triple->value,ocflag->type)); stat = ocset_curlopt(state,ocflag->flag,cvt(triple->value,ocflag->type));
} }
done: done:
if(hostport && hostport != "") free(hostport); if(hostport && *hostport != "") free(hostport);
return stat; return stat;
} }