Skip to content
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

ARROW-15360: [Python] Check slice bounds in Buffer.slice() #12182

Closed
wants to merge 2 commits into from

Conversation

pitrou
Copy link
Member

@pitrou pitrou commented Jan 18, 2022

Calling Buffer.slice() with invalid arguments could return a Buffer referencing out-of-bounds memory.
With this change, an IndexError is raised instead.

Note that Buffer.__getitem__() is unaffected, as it applies Python slice semantics: indices out of bounds are automatically clamped.

@github-actions
Copy link

Copy link
Contributor

@edponce edponce left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Looks good!

python/pyarrow/io.pxi Outdated Show resolved Hide resolved
Calling Buffer.slice() with invalid arguments could return a Buffer referencing out-of-bounds memory.
With this change, an IndexError is raised instead.

Note that Buffer.__getitem__() is unaffected, as it applies Python slice semantics:
indices out of bounds are automatically clamped.
Copy link
Member

@kszucs kszucs left a comment

Choose a reason for hiding this comment

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

Thanks Antoine!

@pitrou pitrou closed this in fd580db Jan 19, 2022
@pitrou pitrou deleted the ARROW-15360-buffer-slice branch January 19, 2022 14:09
@ursabot
Copy link

ursabot commented Jan 19, 2022

Benchmark runs are scheduled for baseline = 09f23ed and contender = fd580db. fd580db is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.0% ⬆️0.36%] ursa-i9-9960x
[Finished ⬇️0.78% ⬆️0.09%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants