diff options
author | Linus Nordberg <linus@nordberg.se> | 2015-01-16 16:31:02 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2015-01-16 16:51:10 +0100 |
commit | ed86dbc57e00173534ceeb325d209e8a11b0d569 (patch) | |
tree | f90b2a621286a3dd85351449718dd41456dfb11b /hash.c | |
parent | 8dd3a960d5bc2bae572511a4aa3df5d85f92dc26 (diff) |
Fix use-after-free in hash_extract().
Patch by Stephen Röttger.
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -92,6 +92,7 @@ void *hash_read(struct hash *h, void *key, uint32_t keylen) { void *hash_extract(struct hash *h, void *key, uint32_t keylen) { struct list_node *ln; struct hash_entry *e; + void *data; if (!h) return 0; @@ -101,9 +102,10 @@ void *hash_extract(struct hash *h, void *key, uint32_t keylen) { if (e->keylen == keylen && !memcmp(e->key, key, keylen)) { free(e->key); list_removedata(h->hashlist, e); + data = e->data; free(e); pthread_mutex_unlock(&h->mutex); - return e->data; + return data; } } pthread_mutex_unlock(&h->mutex); |