8000 rgbmatrix: validate width= constructor parameter · jepler/circuitpython@f7eefef · GitHub
[go: up one dir, main page]

Skip to content

Commit f7eefef

Browse files
committed
rgbmatrix: validate width= constructor parameter
In adafruit#3482, @cwalther noted that, hypothetically, a zero byte allocation could be made in the RGBMatrix constructor. Ensure that width is positive. Height was already checked against the number of RGB pins if it was specified, so zero is ruled out there as well.
1 parent 6bfcb01 commit f7eefef

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

shared-bindings/rgbmatrix/RGBMatrix.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n
210210
}
211211
}
212212

213+
if (args[ARG_width] <= 0) {
214+
mp_raise_ValueError(translate("width must be greater than zero"));
215+
}
216+
213217
preflight_pins_or_throw(clock_pin, rgb_pins, rgb_count, true);
214218

215219
mp_obj_t framebuffer = args[ARG_framebuffer].u_obj;

0 commit comments

Comments
 (0)
0