From 5779283a52a1369cccbe1a1d314e2ec8ac949e0f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 19 Oct 2008 20:17:16 +0000 Subject: [PATCH] attempt to fix or allow further detection of an elusive icc SIGSEGV --- lib/easy.c | 5 ++++- lib/hash.c | 4 ++++ lib/hostip.c | 1 + lib/llist.c | 3 +++ lib/multi.c | 2 ++ lib/share.c | 4 +++- lib/url.c | 5 ++++- 7 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/easy.c b/lib/easy.c index 04a219cbb..2c2490142 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 095fa7028..39c7a079d 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 05b40e323..3a5f642fb 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 cd9edad63..0d08321c6 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 63db12a21..e503a11a2 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 6430611b3..838a15916 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 040a64cd1..a21cda0ae 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);