Skip to content

Fix RoaringBitmapIterator use-after-free by retaining its source bitmap - #27

Merged
lemire merged 1 commit into
RoaringBitmap:masterfrom
jgr-gh:fix_iterator
Aug 21, 2026
Merged

Fix RoaringBitmapIterator use-after-free by retaining its source bitmap#27
lemire merged 1 commit into
RoaringBitmap:masterfrom
jgr-gh:fix_iterator

Conversation

@jgr-gh

@jgr-gh jgr-gh commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

makeIterator() passed the raw C pointer into RoaringBitmapIterator without keeping the RoaringBitmap that owns the pointer alive. If the bitmap got deallocated mid-iteration (for example, when iterating a temporary bitmap), the program can crash or return wrong results. The fix is to keep a reference to the source bitmap in RoaringBitmapIterator. I confirmed the fix building with ASAN (--sanitize=address).

@lemire

lemire commented Aug 21, 2026

Copy link
Copy Markdown
Member

Looks good.

@lemire
lemire merged commit 42b9879 into RoaringBitmap:master Aug 21, 2026
1 check passed
@jgr-gh
jgr-gh deleted the fix_iterator branch August 21, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants