++host_part;
*host = curlx_memdup0(host_part, len - (host_part - input));
if(!*host) {
- curlx_free(*iface);
- *iface = NULL;
+ curlx_safefree(*iface);
return CURLE_OUT_OF_MEMORY;
}
return CURLE_OK;
return GSS_S_FAILURE;
}
- curlx_free(*context);
- *context = NULL;
+ curlx_safefree(*context);
*min = 0;
return GSS_S_COMPLETE;
* the error path) */
ftpc->ctl_valid = FALSE; /* mark control connection as bad */
connclose(conn, "FTP: out of memory!"); /* mark for connection closure */
- curlx_free(ftpc->prevpath);
- ftpc->prevpath = NULL; /* no path remembering */
+ curlx_safefree(ftpc->prevpath); /* no path remembering */
}
else { /* remember working directory for connection reuse */
const char *rawPath = ftpc->rawpath;
DEBUGASSERT(wc->ftpwc == NULL);
Curl_llist_destroy(&wc->filelist, NULL);
- curlx_free(wc->path);
- wc->path = NULL;
- curlx_free(wc->pattern);
- wc->pattern = NULL;
+ curlx_safefree(wc->path);
+ curlx_safefree(wc->pattern);
wc->state = CURLWC_INIT;
curlx_free(wc);
*wcp = NULL;
info->httpauthpicked = 0;
info->numconnects = 0;
- curlx_free(info->contenttype);
- info->contenttype = NULL;
-
- curlx_free(info->wouldredirect);
- info->wouldredirect = NULL;
+ curlx_safefree(info->contenttype);
+ curlx_safefree(info->wouldredirect);
memset(&info->primary, 0, sizeof(info->primary));
info->retry_after = 0;
it might have been used in the proxy connect, but if we have got a header
with the user-agent string specified, we erase the previously made string
here. */
- if(Curl_checkheaders(data, STRCONST("User-Agent"))) {
- curlx_free(data->state.aptr.uagent);
- data->state.aptr.uagent = NULL;
- }
+ if(Curl_checkheaders(data, STRCONST("User-Agent")))
+ curlx_safefree(data->state.aptr.uagent);
return CURLE_OK;
}
if(data->multi->xfer_buf &&
data->set.buffer_size > data->multi->xfer_buf_len) {
/* not large enough, get a new one */
- curlx_free(data->multi->xfer_buf);
- data->multi->xfer_buf = NULL;
+ curlx_safefree(data->multi->xfer_buf);
data->multi->xfer_buf_len = 0;
}
if(data->multi->xfer_ulbuf &&
data->set.upload_buffer_size > data->multi->xfer_ulbuf_len) {
/* not large enough, get a new one */
- curlx_free(data->multi->xfer_ulbuf);
- data->multi->xfer_ulbuf = NULL;
+ curlx_safefree(data->multi->xfer_ulbuf);
data->multi->xfer_ulbuf_len = 0;
}
if(data->multi->xfer_sockbuf && blen > data->multi->xfer_sockbuf_len) {
/* not large enough, get a new one */
- curlx_free(data->multi->xfer_sockbuf);
- data->multi->xfer_sockbuf = NULL;
+ curlx_safefree(data->multi->xfer_sockbuf);
data->multi->xfer_sockbuf_len = 0;
}
curlx_safefree(no_proxy);
if(proxy && (!*proxy || (conn->scheme->flags & PROTOPT_NONETWORK))) {
- curlx_free(proxy); /* Do not bother with an empty proxy string
- or if the protocol does not work with network */
- proxy = NULL;
+ curlx_safefree(proxy); /* Do not bother with an empty proxy string
+ or if the protocol does not work with network */
}
if(pre_proxy && (!*pre_proxy ||
(conn->scheme->flags & PROTOPT_NONETWORK))) {
- curlx_free(pre_proxy); /* Do not bother with an empty socks proxy string
- or if the protocol does not work with
- network */
- pre_proxy = NULL;
+ curlx_safefree(pre_proxy); /* Do not bother with an empty socks proxy
+ string or if the protocol does not work
+ with network */
}
/***********************************************************************
krb5->p_identity, NULL, NULL,
krb5->credentials, NULL);
if(status != SEC_E_OK) {
- curlx_free(krb5->credentials);
- krb5->credentials = NULL;
+ curlx_safefree(krb5->credentials);
return CURLE_LOGIN_DENIED;
}
/* Free our security context */
if(krb5->context) {
Curl_pSecFn->DeleteSecurityContext(krb5->context);
- curlx_free(krb5->context);
- krb5->context = NULL;
+ curlx_safefree(krb5->context);
}
/* Free our credentials handle */
if(krb5->credentials) {
Curl_pSecFn->FreeCredentialsHandle(krb5->credentials);
- curlx_free(krb5->credentials);
- krb5->credentials = NULL;
+ curlx_safefree(krb5->credentials);
}
/* Free our identity */
ntlm->p_identity, NULL, NULL,
ntlm->credentials, NULL);
if(status != SEC_E_OK) {
- curlx_free(ntlm->credentials);
- ntlm->credentials = NULL;
+ curlx_safefree(ntlm->credentials);
return CURLE_LOGIN_DENIED;
}
/* Free our security context */
if(ntlm->context) {
Curl_pSecFn->DeleteSecurityContext(ntlm->context);
- curlx_free(ntlm->context);
- ntlm->context = NULL;
+ curlx_safefree(ntlm->context);
}
/* Free our credentials handle */
if(ntlm->credentials) {
Curl_pSecFn->FreeCredentialsHandle(ntlm->credentials);
- curlx_free(ntlm->credentials);
- ntlm->credentials = NULL;
+ curlx_safefree(ntlm->credentials);
}
/* Free our identity */
nego->p_identity, NULL, NULL,
nego->credentials, NULL);
if(nego->status != SEC_E_OK) {
- curlx_free(nego->credentials);
- nego->credentials = NULL;
+ curlx_safefree(nego->credentials);
return CURLE_AUTH_ERROR;
}
/* Free our security context */
if(nego->context) {
Curl_pSecFn->DeleteSecurityContext(nego->context);
- curlx_free(nego->context);
- nego->context = NULL;
+ curlx_safefree(nego->context);
}
/* Free our credentials handle */
if(nego->credentials) {
Curl_pSecFn->FreeCredentialsHandle(nego->credentials);
- curlx_free(nego->credentials);
- nego->credentials = NULL;
+ curlx_safefree(nego->credentials);
}
/* Free our identity */
err_desc = curlx_malloc(size + 1);
if(err_desc) {
if(!CFStringGetCString(error_ref, err_desc, size,
- kCFStringEncodingUTF8)) {
- curlx_free(err_desc);
- err_desc = NULL;
- }
+ kCFStringEncodingUTF8))
+ curlx_safefree(err_desc);
}
}
infof(data, "Apple SecTrust failure %ld%s%s", code,
ci->certinfo[i] = NULL;
}
- curlx_free(ci->certinfo); /* free the actual array too */
- ci->certinfo = NULL;
+ curlx_safefree(ci->certinfo); /* free the actual array too */
ci->num_of_certs = 0;
}
}
static ParameterError getstr(char **str, const char *val, bool allowblank)
{
- if(*str) {
- curlx_free(*str);
- *str = NULL;
- }
+ if(*str)
+ curlx_safefree(*str);
DEBUGASSERT(val);
if(!allowblank && !val[0])
return PARAM_BLANK_STRING;
static ParameterError getstrn(char **str, const char *val,
size_t len, bool allowblank)
{
- if(*str) {
- curlx_free(*str);
- *str = NULL;
- }
+ if(*str)
+ curlx_safefree(*str);
DEBUGASSERT(val);
if(!allowblank && !val[0])
return PARAM_BLANK_STRING;
t518_num_open.rlim_cur++)
if(t518_testfd[t518_num_open.rlim_cur] > 0)
curlx_close(t518_testfd[t518_num_open.rlim_cur]);
- curlx_free(t518_testfd);
- t518_testfd = NULL;
+ curlx_safefree(t518_testfd);
}
static int t518_fopen_works(void)
curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
t518_store_errmsg(strbuff, errno);
curl_mfprintf(stderr, "%s\n", t518_msgbuff);
- curlx_free(t518_testfd);
- t518_testfd = NULL;
+ curlx_safefree(t518_testfd);
curlx_free(memchunk);
return -8;
}
t518_testfd[t518_num_open.rlim_cur] >= 0;
t518_num_open.rlim_cur++)
curlx_close(t518_testfd[t518_num_open.rlim_cur]);
- curlx_free(t518_testfd);
- t518_testfd = NULL;
+ curlx_safefree(t518_testfd);
curlx_free(memchunk);
return -9;
}
t537_num_open.rlim_cur++)
if(t537_testfd[t537_num_open.rlim_cur] > 0)
curlx_close(t537_testfd[t537_num_open.rlim_cur]);
- curlx_free(t537_testfd);
- t537_testfd = NULL;
+ curlx_safefree(t537_testfd);
}
static int t537_fopen_works(void)
curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
t537_store_errmsg(strbuff, errno);
curl_mfprintf(stderr, "%s\n", t537_msgbuff);
- curlx_free(t537_testfd);
- t537_testfd = NULL;
+ curlx_safefree(t537_testfd);
curlx_free(memchunk);
return -7;
}
continue_reading = FALSE;
curlx_fclose(fInCert);
if(!continue_reading) {
- curlx_free(data);
+ curlx_safefree(data);
datasize = 0;
- data = NULL;
}
}
}
goto error;
dns = Curl_hash_pick(&multi->dnscache.entries,
entry_id, strlen(entry_id) + 1);
- curlx_free(entry_id);
- entry_id = NULL;
+ curlx_safefree(entry_id);
addr = dns ? dns->addr : NULL;
dns = Curl_hash_pick(&multi->dnscache.entries,
entry_id, strlen(entry_id) + 1);
- curlx_free(entry_id);
- entry_id = NULL;
+ curlx_safefree(entry_id);
addr = dns ? dns->addr : NULL;