Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7ba3ea9

Browse filesBrowse files
committed
Fix out of bounds read in backend_tk.
Really, we should specify somewhere how rounding of bboxes passed to blit() (and to copy_from_bbox()) works, but at least this patch will avoid out-of-bounds reads in the tk blit.
1 parent 146de7f commit 7ba3ea9
Copy full SHA for 7ba3ea9

File tree

Expand file treeCollapse file tree

1 file changed

+5
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-2
lines changed

‎lib/matplotlib/backends/_backend_tk.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/_backend_tk.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ def blit(photoimage, aggimage, offsets, bbox=None):
6767
dataptr = (height, width, data.ctypes.data)
6868
if bbox is not None:
6969
(x1, y1), (x2, y2) = bbox.__array__()
70-
bboxptr = (math.floor(x1), math.ceil(x2),
71-
math.floor(y1), math.ceil(y2))
70+
x1 = max(math.floor(x1), 0)
71+
x2 = min(math.ceil(x2), width)
72+
y1 = max(math.floor(y1), 0)
73+
y2 = min(math.ceil(y2), height)
74+
bboxptr = (x1, x2, y1, y2)
7275
else:
7376
photoimage.blank()
7477
bboxptr = (0, width, 0, height)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.