Skip to content

Commit 8b9e933

Browse files
authored
Merge pull request adafruit#1755 from tannewt/fix_tilegrid_bounds_check
Always check TileGrid's x, y
2 parents df058c9 + 04a4e8a commit 8b9e933

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

shared-bindings/displayio/TileGrid.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,10 @@ STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t v
259259
mp_obj_get_array_fixed_n(index_obj, 2, &items);
260260
x = mp_obj_get_int(items[0]);
261261
y = mp_obj_get_int(items[1]);
262-
if (x >= common_hal_displayio_tilegrid_get_width(self) || y >= common_hal_displayio_tilegrid_get_height(self)) {
263-
mp_raise_IndexError(translate("tile index out of bounds"));
264-
}
262+
}
263+
if (x >= common_hal_displayio_tilegrid_get_width(self) ||
264+
y >= common_hal_displayio_tilegrid_get_height(self)) {
265+
mp_raise_IndexError(translate("tile index out of bounds"));
265266
}
266267

267268
if (value_obj == MP_OBJ_SENTINEL) {

0 commit comments

Comments
 (0)