Skip to content

fix soundness when attempting to create a view of an array with unrepresentable strides - #578

Open
Icxolu wants to merge 2 commits into
PyO3:mainfrom
Icxolu:fix/575
Open

Icxolu wants to merge 2 commits into
PyO3:mainfrom
Icxolu:fix/575

Conversation

@Icxolu

@Icxolu Icxolu commented Nov 5, 2026

Copy link
Copy Markdown
Member

Closes #575

Comment thread src/array.rs Outdated
if strides.iter().any(|strides| *strides < 0) {
if strides
.iter()
.any(|strides| *strides < 0 || *strides as usize % mem::size_of::<N>() != 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should this get new test(s)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, we probably should add one. I will try to give this another pass in the coming days. Thanks for taking a look, much appreciated!

Comment thread src/array.rs Resolved
Co-authored-by: MarkusSintonen <12939780+MarkusSintonen@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

Safe as_array segfaults or corrupts data when a stride is not a multiple of the item size

2 participants