Skip to content
Verified Commit ad8f0094 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

AkRanges: mark FilterIterator as an InputIterator

Normally the AkRanges' BaseIterator inherits the iterator category from the
source iterator, which is RandomAccessIterator for most Qt containers.
In case of our FilterIterator, however, we reduce it to a simple
InputIterator. Not only because we don't implement correctly all of the
required RandomAccessIterator semantics (which we could do), but it
would actually have negative performance impact with STL algorithms like
std::find(), since some of the operations would be costly to perform on
the FilterIterator (e.g. last-first would require to loop over the
entire container).

This was actually discovered by ASAN detecting heap-buffer-overflow in
AkRangesTest::testNone() as the loop tried to dereference past-the-end
iterator.
parent 31578c12
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment