Ensure bounds in add_dline()

This commit is contained in:
Kovid Goyal 2017-12-13 13:45:11 +05:30
parent d097403a12
commit 54b802f1e6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -93,6 +93,8 @@ def add_dline(buf, cell_width, position, thickness, cell_height):
top -= deficit - 1
else:
top -= deficit
top = max(0, min(top, cell_height - 1))
bottom = max(0, min(bottom, cell_height - 1))
for y in {top, bottom}:
ctypes.memset(ctypes.addressof(buf) + (cell_width * y), 255, cell_width)