data->set.cookiesession);
list = list->next;
}
- Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
curl_slist_free_all(data->change.cookielist); /* clean up list */
data->change.cookielist = NULL; /* don't do this again! */
+ Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
}
if(!finfo)
return;
- if(finfo->b_data)
- free(finfo->b_data);
+ Curl_safefree(finfo->b_data);
free(finfo);
}
struct curl_hash *h = (struct curl_hash *) user;
struct curl_hash_element *e = (struct curl_hash_element *) element;
- if(e->key)
- free(e->key);
+ Curl_safefree(e->key);
- if(e->ptr)
+ if(e->ptr) {
h->dtor(e->ptr);
+ e->ptr = NULL;
+ }
+
+ e->key_len = 0;
free(e);
}
}
free(h->table);
h->table = NULL;
+ h->slots = 0;
return 1; /* failure */
}
}
return 0; /* fine */
}
- else
+ else {
+ h->slots = 0;
return 1; /* failure */
+ }
}
struct curl_hash *
he = le->ptr;
if(h->comp_func(he->key, he->key_len, key, key_len)) {
Curl_llist_remove(l, le, (void *) h);
+ --h->size;
return 0;
}
}
free(h->table);
h->table = NULL;
+ h->size = 0;
+ h->slots = 0;
}
void
struct curl_llist *list;
list = malloc(sizeof(struct curl_llist));
- if(NULL == list)
+ if(!list)
return NULL;
llist_init(list, dtor);
return (CURLM *) multi;
error:
- if(multi->sockhash)
- Curl_hash_destroy(multi->sockhash);
- if(multi->hostcache)
- Curl_hash_destroy(multi->hostcache);
- if(multi->connc)
- Curl_rm_connc(multi->connc);
+
+ Curl_hash_destroy(multi->sockhash);
+ multi->sockhash = NULL;
+ Curl_hash_destroy(multi->hostcache);
+ multi->hostcache = NULL;
+ Curl_rm_connc(multi->connc);
+ multi->connc = NULL;
free(multi);
return NULL;
}
Curl_rm_connc(multi->connc);
+ multi->connc = NULL;
/* remove the pending list of messages */
Curl_llist_destroy(multi->msglist, NULL);
equivalent of curl_slist_append but doesn't strdup() the given data as
like in this place the extra malloc/free is totally pointless */
nl = curl_slist_append(ci->certinfo[certnum], output);
+ free(output);
if(!nl) {
curl_slist_free_all(ci->certinfo[certnum]);
ci->certinfo[certnum] = NULL;
else
ci->certinfo[certnum] = nl;
- free(output);
-
return res;
}
/* free the connection cache if allocated privately */
Curl_rm_connc(data->state.connc);
+ data->state.connc = NULL;
}
}
curl_multi_cleanup(). */
void Curl_rm_connc(struct conncache *c)
{
+ if(!c)
+ return;
+
if(c->connects) {
long i;
- for(i = 0; i < c->num; ++i)
+ for(i = 0; i < c->num; ++i) {
conn_free(c->connects[i]);
-
+ c->connects[i] = NULL;
+ }
free(c->connects);
+ c->connects = NULL;
}
+ c->num = 0;
free(c);
}
/* append the cookie file name to the list of file names, and deal with
them later */
cl = curl_slist_append(data->change.cookielist, argptr);
-
- if(!cl)
+ if(!cl) {
+ curl_slist_free_all(data->change.cookielist);
+ data->change.cookielist = NULL;
return CURLE_OUT_OF_MEMORY;
-
+ }
data->change.cookielist = cl; /* store the list for later use */
}
break;