diff options
author | Daniel Stenberg <daniel@haxx.se> | 2003-09-14 21:17:54 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2003-09-14 21:17:54 +0000 |
commit | 14597475b19a63ae2fc886a7747802f6d26cfa2f (patch) | |
tree | 378975f14d1566c84ee4e41479f7f222d666b19a /lib/hostip.c | |
parent | de3281a3a84e653f901f3955454c6c1249061591 (diff) |
Jeff Pohlmeyer did some marvelous debugging to track this one down. We MUST
NOT free the existing hash entry when we try to add a new one that matches
an existing entry. We now instead free the new one, and make the parent
function use the old entry's struct instead.
Diffstat (limited to 'lib/hostip.c')
-rw-r--r-- | lib/hostip.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/hostip.c b/lib/hostip.c index c397a3c75..3f465a0d0 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -231,15 +231,22 @@ cache_resolv_response(struct SessionHandle *data, return NULL; } - dns->inuse = 0; - dns->addr = addr; - - /* Store it in our dns cache */ - Curl_hash_add(data->hostcache, entry_id, entry_len+1, - (const void *) dns); + dns->inuse = 0; /* init to not used */ + dns->addr = addr; /* this is the address(es) */ + + /* Store the resolved data in our DNS cache. This function may return a + pointer to an existing struct already present in the hash, and it may + return the same argument we pass in. Make no assumptions. */ + dns = Curl_hash_add(data->hostcache, entry_id, entry_len+1, (void *) dns); + if(!dns) { + /* major badness, run away! */ + Curl_freeaddrinfo(addr); + free(entry_id); + return NULL; + } time(&now); - dns->timestamp = now; + dns->timestamp = now; /* used now */ dns->inuse++; /* mark entry as in-use */ |