improved the cleaning up of memory when we fail to resolve names due to
out of memory (thanks to 'runtests.pl -t')
This commit is contained in:
Родитель
08d1da106e
Коммит
4250637e7d
|
@ -164,7 +164,7 @@ Curl_hash_add(curl_hash *h, char *key, size_t key_len, void *p)
|
||||||
/* couldn't insert it, destroy the 'he' element again */
|
/* couldn't insert it, destroy the 'he' element again */
|
||||||
hash_element_dtor(h, he);
|
hash_element_dtor(h, he);
|
||||||
}
|
}
|
||||||
h->dtor(p); /* remove the NEW entry */
|
|
||||||
return NULL; /* failure */
|
return NULL; /* failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
lib/hostip.c
11
lib/hostip.c
|
@ -314,6 +314,7 @@ Curl_cache_addr(struct SessionHandle *data,
|
||||||
char *entry_id;
|
char *entry_id;
|
||||||
size_t entry_len;
|
size_t entry_len;
|
||||||
struct Curl_dns_entry *dns;
|
struct Curl_dns_entry *dns;
|
||||||
|
struct Curl_dns_entry *dns2;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
/* Create an entry id, based upon the hostname and port */
|
/* Create an entry id, based upon the hostname and port */
|
||||||
|
@ -325,7 +326,6 @@ Curl_cache_addr(struct SessionHandle *data,
|
||||||
/* Create a new cache entry */
|
/* Create a new cache entry */
|
||||||
dns = (struct Curl_dns_entry *) malloc(sizeof(struct Curl_dns_entry));
|
dns = (struct Curl_dns_entry *) malloc(sizeof(struct Curl_dns_entry));
|
||||||
if (!dns) {
|
if (!dns) {
|
||||||
Curl_freeaddrinfo(addr);
|
|
||||||
free(entry_id);
|
free(entry_id);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -336,14 +336,15 @@ Curl_cache_addr(struct SessionHandle *data,
|
||||||
/* Store the resolved data in our DNS cache. This function may return a
|
/* 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
|
pointer to an existing struct already present in the hash, and it may
|
||||||
return the same argument we pass in. Make no assumptions. */
|
return the same argument we pass in. Make no assumptions. */
|
||||||
dns = Curl_hash_add(data->hostcache, entry_id, entry_len+1, (void *)dns);
|
dns2 = Curl_hash_add(data->hostcache, entry_id, entry_len+1, (void *)dns);
|
||||||
if(!dns) {
|
if(!dns2) {
|
||||||
/* Major badness, run away. When this happens, the 'dns' data has
|
/* Major badness, run away. */
|
||||||
already been cleared up by Curl_hash_add(). */
|
free(dns);
|
||||||
free(entry_id);
|
free(entry_id);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
time(&now);
|
time(&now);
|
||||||
|
dns = dns2;
|
||||||
|
|
||||||
dns->timestamp = now; /* used now */
|
dns->timestamp = now; /* used now */
|
||||||
dns->inuse++; /* mark entry as in-use */
|
dns->inuse++; /* mark entry as in-use */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче