Skip to content

Commit 9a0bb31

Browse files
committed
Add precondition to prevent access out of bounds
1 parent a861fc1 commit 9a0bb31

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

stdlib/public/Cxx/CxxRandomAccessCollection.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extension CxxRandomAccessCollection {
4444
// Not using CxxIterator here to avoid making a copy of the collection.
4545
var rawIterator = __beginUnsafe()
4646
rawIterator += RawIterator.Distance(index)
47+
precondition(__endUnsafe() - rawIterator <= 0, "C++ iterator access out of bounds")
4748
yield rawIterator.pointee
4849
}
4950
}

0 commit comments

Comments
 (0)