From 029150ac3b075a8e936e6c722c6f63cf80594e2a Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sun, 15 Aug 2021 19:46:20 -0500 Subject: [PATCH] validate initial point is in-bounds --- shared-bindings/bitmaptools/__init__.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index e566168879..761a94c4c9 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -345,6 +345,12 @@ STATIC mp_obj_t bitmaptools_obj_boundary_fill(size_t n_args, const mp_obj_t *pos int16_t x = args[ARG_x].u_int; int16_t y = args[ARG_y].u_int; + if (x < 0 || x >= destination->width) { + mp_raise_ValueError(translate("out of range of target")); + } + if (y < 0 || y >= destination->height) { + mp_raise_ValueError(translate("out of range of target")); + } common_hal_bitmaptools_boundary_fill(destination, x, y, value, background_value);