-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MNT: protect from out-of-bounds data access at the c level #14478
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e50cd5b
MNT: protect from out-of-bounds data access at the c level
tacaswell 9d1b200
MNT: remove print + pep8
tacaswell 44aa923
STY: reformat c++ conditional
tacaswell 774f558
TST: fail gracefully if backend can not be imported
tacaswell 0f5fe5d
TST: hide possible unavailable import
tacaswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
import numpy as np | ||
from matplotlib import pyplot as plt | ||
|
||
|
||
@pytest.mark.backend('TkAgg', skip_on_importerror=True) | ||
def test_blit(): | ||
from matplotlib.backends import _tkagg | ||
def evil_blit(photoimage, aggimage, offsets, bboxptr): | ||
data = np.asarray(aggimage) | ||
height, width = data.shape[:2] | ||
dataptr = (height, width, data.ctypes.data) | ||
_tkagg.blit( | ||
photoimage.tk.interpaddr(), str(photoimage), dataptr, offsets, | ||
bboxptr) | ||
|
||
fig, ax = plt.subplots() | ||
for bad_boxes in ((-1, 2, 0, 2), | ||
(2, 0, 0, 2), | ||
(1, 6, 0, 2), | ||
(0, 2, -1, 2), | ||
(0, 2, 2, 0), | ||
(0, 2, 1, 6)): | ||
with pytest.raises(ValueError): | ||
evil_blit(fig.canvas._tkphoto, | ||
np.ones((4, 4, 4)), | ||
(0, 1, 2, 3), | ||
bad_boxes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it easier this way "y1 is smaller than 0 or larger than y2".
0 > y1
sort of ties a knot in my brain. 😄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is fair, but having all of the
>
go the same way is also helpful..Moot now that @efiring merged it..