mirror of https://github.com/moparisthebest/curl
make sure that hash_add() has no allocated resources left in case it
returns NULL
This commit is contained in:
parent
50e7545118
commit
947e656367
15
lib/hash.c
15
lib/hash.c
|
@ -156,14 +156,15 @@ Curl_hash_add(curl_hash *h, char *key, size_t key_len, void *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
he = mk_hash_element(key, key_len, p);
|
he = mk_hash_element(key, key_len, p);
|
||||||
if (!he)
|
if (he) {
|
||||||
return NULL; /* failure */
|
if(Curl_llist_insert_next(l, l->tail, he)) {
|
||||||
|
++h->size;
|
||||||
if (Curl_llist_insert_next(l, l->tail, he)) {
|
return p; /* return the new entry */
|
||||||
++h->size;
|
}
|
||||||
return p; /* return the new entry */
|
/* couldn't insert it, destroy the 'he' element again */
|
||||||
|
hash_element_dtor(h, he);
|
||||||
}
|
}
|
||||||
|
h->dtor(p); /* remove the NEW entry */
|
||||||
return NULL; /* failure */
|
return NULL; /* failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue