Skip to content
Snippets Groups Projects
Commit e64dacb4 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

better checking that strdup() works

parent fff01f24
No related branches found
No related tags found
No related merge requests found
......@@ -127,9 +127,17 @@ 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);
he->key_len = key_len;
he->ptr = (void *) p;
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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment