fx.collections: hashtable: add bounds checking to iterator
This commit is contained in:
@@ -623,6 +623,10 @@ static const fx_value *iterator_get_value(const fx_iterator *obj)
|
|||||||
struct table_item *table = it->_h_p->t_items;
|
struct table_item *table = it->_h_p->t_items;
|
||||||
size_t capacity = primes[it->_h_p->t_max_index];
|
size_t capacity = primes[it->_h_p->t_max_index];
|
||||||
|
|
||||||
|
if (it->i >= capacity) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (table[it->i].i_item) {
|
if (table[it->i].i_item) {
|
||||||
return &it->item_value;
|
return &it->item_value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user