Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 3817fe4c0b26d13f04c3b692e14d193308fa3c50 https://github.com/WebKit/WebKit/commit/3817fe4c0b26d13f04c3b692e14d193308fa3c50 Author: Geoffrey Garen <gga...@apple.com> Date: 2024-11-01 (Fri, 01 Nov 2024)
Changed paths: M Source/WTF/wtf/IndexedRange.h Log Message: ----------- IndexedRangeIterator should be safer https://bugs.webkit.org/show_bug.cgi?id=282472 rdar://139101044 Reviewed by Chris Dumez. I originally built IndexedRangeIterator assuming you would only use it inside a range-based for loop that implicitly checks the end iterator. But no mechanism actually prevents a programmer from using it directly and not checking the end iterator. So I added explicit checks. Testing locally in some toy examples shows that clang -O3 evaporates all the checks when the iterator is used as intended. * Source/WTF/wtf/IndexedRange.h: (WTF::BoundsCheckedIterator::BoundsCheckedIterator): (WTF::BoundsCheckedIterator::operator++): (WTF::BoundsCheckedIterator::operator* const): (WTF::BoundsCheckedIterator::operator== const): (WTF::IndexedRangeIterator::IndexedRangeIterator): (WTF::IndexedRange::IndexedRange): (WTF::IndexedRange::begin): (WTF::IndexedRange::end): Canonical link: https://commits.webkit.org/286046@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes