8000 Fix out of bounds read in backend_tk. · matplotlib/matplotlib@7ba3ea9 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 7ba3ea9

Browse 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 r 8000 eads in the tk blit.
1 parent 146de7f commit 7ba3ea9

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