diff --git a/lib/easy.c b/lib/easy.c index 04a219cbbae2ea56eb0b425759918270b23809f4..2c2490142908ffc69764d65ac959c47a0c063f7e 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -502,9 +502,12 @@ CURLcode curl_easy_perform(CURL *curl) /* global dns cache was requested but still isn't */ struct curl_hash *ptr; - if(data->dns.hostcachetype == HCACHE_PRIVATE) + if(data->dns.hostcachetype == HCACHE_PRIVATE) { /* if the current cache is private, kill it first */ Curl_hash_destroy(data->dns.hostcache); + data->dns.hostcachetype = HCACHE_NONE; + data->dns.hostcache = NULL; + } ptr = Curl_global_host_cache_init(); if(ptr) { diff --git a/lib/hash.c b/lib/hash.c index 095fa7028945feca3da5548ea74fd42f558efa40..39c7a079df808e8d327332508a96efb9be18a8ff 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -44,6 +44,7 @@ hash_element_dtor(void *user, void *element) h->dtor(e->ptr); + memset(e, 0, sizeof(struct curl_hash_element)); free(e); } @@ -232,6 +233,7 @@ Curl_hash_clean(struct curl_hash *h) for (i = 0; i < h->slots; ++i) { Curl_llist_destroy(h->table[i], (void *) h); + h->table[i] = NULL; } free(h->table); @@ -269,6 +271,8 @@ Curl_hash_destroy(struct curl_hash *h) return; Curl_hash_clean(h); + + memset(h, 0, sizeof(struct struct curl_hash)); free(h); } diff --git a/lib/hostip.c b/lib/hostip.c index 05b40e323869bc5e898afda1dd4d40ade7635b3d..3a5f642fb9887f03c6af382e55d649947f7b3670 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -695,6 +695,7 @@ static void freednsentry(void *freethis) Curl_freeaddrinfo(p->addr); + memset(p, 0, sizeof(struct Curl_dns_entry)); free(p); } diff --git a/lib/llist.c b/lib/llist.c index cd9edad63c81525d22870831df1f6adc09c6c990..0d08321c670bdcdbc6f7638526a3a654cfa72225 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -113,6 +113,8 @@ Curl_llist_remove(struct curl_llist *list, struct curl_llist_element *e, } list->dtor(user, e->ptr); + + memset(e, 0, sizeof(struct curl_llist_element)); free(e); --list->size; @@ -126,6 +128,7 @@ Curl_llist_destroy(struct curl_llist *list, void *user) while(list->size > 0) Curl_llist_remove(list, list->tail, user); + memset(list, 0, sizeof(struct curl_llist)); free(list); } } diff --git a/lib/multi.c b/lib/multi.c index 63db12a2193c00623ab4de776fac8541e8c344cc..e503a11a2cb00e67197283e29e129c3efc27cb76 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -1551,6 +1551,8 @@ CURLMcode curl_multi_cleanup(CURLM *multi_handle) multi->type = 0; /* not good anymore */ Curl_hash_destroy(multi->hostcache); Curl_hash_destroy(multi->sockhash); + multi->hostcache = NULL; + multi->sockhash = NULL; /* go over all connections that have close actions */ for(i=0; i< multi->connc->num; i++) { diff --git a/lib/share.c b/lib/share.c index 6430611b35bc8c6d53031936e1253e21b981f4f3..838a159164c905250bdd7b5a7f84fcafb442d3fd 100644 --- a/lib/share.c +++ b/lib/share.c @@ -168,8 +168,10 @@ curl_share_cleanup(CURLSH *sh) return CURLSHE_IN_USE; } - if(share->hostcache) + if(share->hostcache) { Curl_hash_destroy(share->hostcache); + share->hostcache = NULL; + } #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) if(share->cookies) diff --git a/lib/url.c b/lib/url.c index 040a64cd1495a1097bb434d8ae2df8f4529d477b..a21cda0aeceee186b4711f5510f616586964d5df 100644 --- a/lib/url.c +++ b/lib/url.c @@ -450,8 +450,11 @@ CURLcode Curl_close(struct SessionHandle *data) return CURLE_OK; } - if(data->dns.hostcachetype == HCACHE_PRIVATE) + if(data->dns.hostcachetype == HCACHE_PRIVATE) { Curl_hash_destroy(data->dns.hostcache); + data->dns.hostcachetype = HCACHE_NONE; + data->dns.hostcache = NULL; + } if(data->state.rangestringalloc) free(data->state.range);