@@ -395,8 +395,8 @@ static mp_obj_t displayio_tilegrid_obj_get_inverted(mp_obj_t self_in, mp_obj_t t
395395 mp_obj_get_array_fixed_n (tile_coords , 2 , & tile_coords_items );
396396 uint16_t x = 0 ;
397397 uint16_t y = 0 ;
398- x = mp_obj_get_int (tile_coords_items [0 ]);
399- y = mp_obj_get_int (tile_coords_items [1 ]);
398+ x = mp_arg_validate_int_range ( mp_obj_get_int (tile_coords_items [0 ]), 0 , self -> width_in_tiles - 1 , MP_QSTR_x );
399+ y = mp_arg_validate_int_range ( mp_obj_get_int (tile_coords_items [1 ]), 0 , self -> height_in_tiles - 1 , MP_QSTR_y );
400400
401401 return mp_obj_new_bool (common_hal_displayio_tilegrid_get_inverted (self , x , y ));
402402}
@@ -412,8 +412,8 @@ static mp_obj_t displayio_tilegrid_obj_set_inverted(mp_obj_t self_in, mp_obj_t t
412412 mp_obj_get_array_fixed_n (tile_coords , 2 , & tile_coords_items );
413413 uint16_t x = 0 ;
414414 uint16_t y = 0 ;
415- x = mp_obj_get_int (tile_coords_items [0 ]);
416- y = mp_obj_get_int (tile_coords_items [1 ]);
415+ x = mp_arg_validate_int_range ( mp_obj_get_int (tile_coords_items [0 ]), 0 , self -> width_in_tiles - 1 , MP_QSTR_x );
416+ y = mp_arg_validate_int_range ( mp_obj_get_int (tile_coords_items [1 ]), 0 , self -> height_in_tiles - 1 , MP_QSTR_y );
417417 bool inverted = mp_obj_is_true (inverted_obj );
418418
419419 common_hal_displayio_tilegrid_set_inverted (self , x , y , inverted );
0 commit comments