Skip to content

Add precondition to prevent out-of-bounds access #75266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

susmonteiro
Copy link
Contributor

@susmonteiro susmonteiro commented Jul 16, 2024

The subscript function from CxxRandomAccessCollection did not perform any bounds-checks.
This means that C++ containers that don't provide the operator[] (or C++ containers used in generic contexts) didn't have bounds-checks.

Fixes rdar://126570011

@susmonteiro
Copy link
Contributor Author

@swift-ci please smoke test

@susmonteiro susmonteiro force-pushed the susmonteiro/cxx-precondition-oob branch 2 times, most recently from 9a0bb31 to 2ddbb0c Compare July 17, 2024 15:24
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jul 17, 2024
@susmonteiro
Copy link
Contributor Author

@swift-ci please smoke test

@susmonteiro susmonteiro force-pushed the susmonteiro/cxx-precondition-oob branch from 2ddbb0c to 1085146 Compare July 17, 2024 17:11
Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@susmonteiro
Copy link
Contributor Author

@swift-ci please smoke test

@susmonteiro susmonteiro force-pushed the susmonteiro/cxx-precondition-oob branch from 1085146 to fd0c0cd Compare July 18, 2024 13:17
@susmonteiro
Copy link
Contributor Author

@swift-ci please smoke test

The subscript function from CxxRandomAccessCollection did not perform any bounds-checks.
This means that C++ containers that don't provide the operator[] (or C++ containers used in generic contexts) didn't have bounds-checks.

Fixes rdar://126570011
@susmonteiro susmonteiro force-pushed the susmonteiro/cxx-precondition-oob branch from fd0c0cd to 15e1749 Compare July 18, 2024 14:30
@susmonteiro
Copy link
Contributor Author

@swift-ci please smoke test

@susmonteiro susmonteiro merged commit e2a0be8 into main Jul 18, 2024
3 checks passed
@susmonteiro susmonteiro deleted the susmonteiro/cxx-precondition-oob branch July 18, 2024 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants