Skip to content

Commit

Permalink
util: fix NULL deref in interval tree foreach (#4004)
Browse files Browse the repository at this point in the history
  • Loading branch information
ret2libc authored Nov 27, 2023
1 parent c182663 commit fce44a2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions librz/include/rz_util/rz_intervaltree.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ static inline bool rz_interval_tree_empty(RzIntervalTree *tree) {
}

#define rz_interval_tree_foreach(tree, it, dat) \
for ((it) = rz_rbtree_first(&(tree)->root->node); rz_rbtree_iter_has(&it) && (dat = rz_interval_tree_iter_get(&it)->data); rz_rbtree_iter_next(&(it)))
if ((tree)->root) \
for ((it) = rz_rbtree_first(&(tree)->root->node); rz_rbtree_iter_has(&it) && (dat = rz_interval_tree_iter_get(&it)->data); rz_rbtree_iter_next(&(it)))

#define rz_interval_tree_foreach_prev(tree, it, dat) \
for ((it) = rz_rbtree_last(&(tree)->root->node); rz_rbtree_iter_has(&it) && (dat = rz_rbtree_iter_get(&it, RzIntervalNode, node)->data); rz_rbtree_iter_prev(&(it)))
if ((tree)->root) \
for ((it) = rz_rbtree_last(&(tree)->root->node); rz_rbtree_iter_has(&it) && (dat = rz_rbtree_iter_get(&it, RzIntervalNode, node)->data); rz_rbtree_iter_prev(&(it)))

#endif // RZ_INTERVALTREE_H

0 comments on commit fce44a2

Please sign in to comment.