8000 Merge pull request #14461 from anntzer/tkoutofbounds · matplotlib/matplotlib@1c06de3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c06de3

Browse files
authored
Merge pull request #14461 from anntzer/tkoutofbounds
FIX: out of bounds read in backend_tk.
2 parents 07c716f + 7ba3ea9 commit 1c06de3

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
@@ -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