1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

better checking that strdup() works

This commit is contained in:
Daniel Stenberg 2004-05-10 08:57:18 +00:00
parent fff01f24bf
commit e64dacb40e

View File

@ -127,10 +127,18 @@ mk_hash_element(char *key, size_t key_len, const void *p)
(curl_hash_element *) malloc(sizeof(curl_hash_element));
if(he) {
he->key = strdup(key);
char *dup = strdup(key);
if(dup) {
he->key = dup;
he->key_len = key_len;
he->ptr = (void *) p;
}
else {
/* failed to duplicate the key, free memory and fail */
free(he);
he = NULL;
}
}
return he;
}