public
/
ack.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
cf15e22
)
Fix crash when enumerating uninitialised hashtables.
author
David Given
<dg@cowlark.com>
Fri, 16 Dec 2016 21:12:28 +0000
(22:12 +0100)
committer
David Given
<dg@cowlark.com>
Fri, 16 Dec 2016 21:12:28 +0000
(22:12 +0100)
modules/src/data/hashtable.c
patch
|
blob
|
history
diff --git
a/modules/src/data/hashtable.c
b/modules/src/data/hashtable.c
index
7c895b5
..
d4dba61
100644
(file)
--- a/
modules/src/data/hashtable.c
+++ b/
modules/src/data/hashtable.c
@@
-163,15
+163,12
@@
void* hashtable_pop(struct hashtable* ht)
void* hashtable_next(struct hashtable* ht, struct hashtable_iterator* it)
{
+ lazy_init(ht);
+
while (!it->node)
{
if (it->bucket == ht->num_buckets)
- {
- it->key = it->value = NULL;
- it->bucket = 0;
- it->node = NULL;
- return NULL;
- }
+ goto eof;
it->node = ht->buckets[it->bucket];
if (it->node)
@@
-187,4
+184,10
@@
void* hashtable_next(struct hashtable* ht, struct hashtable_iterator* it)
it->bucket++;
return it->value;
+
+eof:
+ it->key = it->value = NULL;
+ it->bucket = 0;
+ it->node = NULL;
+ return NULL;
}