8000 Merge pull request #14477 from meeseeksmachine/auto-backport-of-pr-14… · matplotlib/matplotlib@6299c88 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6299c88

Browse files
authored
Merge pull request #14477 from meeseeksmachine/auto-backport-of-pr-14461-on-v3.1.x
Backport PR #14461 on branch v3.1.x (Fix out of bounds read in backend_tk.)
2 parents a983c89 + daa153f commit 6299c88

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ def blit(photoimage, aggimage, offsets, bbox=None):
7171
dataptr = (height, width, data.ctypes.data)
7272
if bbox is not None:
7373
(x1, y1), (x2, y2) = bbox.__array__()
74-
bboxptr = (math.floor(x1), math.ceil(x2),
75-
math.floor(y1), math.ceil(y2))
74+
x1 = max(math.floor(x1), 0)
75+
x2 = min(math.ceil(x2), width)
76+
y1 = max(math.floor(y1), 0)
77+
y2 = min(math.ceil(y2), height)
78+
bboxptr = (x1, x2, y1, y2)
7679
else:
7780
photoimage.blank()
7881
bboxptr = (0, width, 0, height)

0 commit comments

Comments
 (0)
0