rgbmatrix: validate width= constructor parameter
In #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.
This commit is contained in:
parent
2bb44f6c4d
commit
176b337611
|
@ -210,6 +210,10 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n
|
|||
}
|
||||
}
|
||||
|
||||
if (args[ARG_width] <= 0) {
|
||||
mp_raise_ValueError(translate("width must be greater than zero"));
|
||||
}
|
||||
|
||||
preflight_pins_or_throw(clock_pin, rgb_pins, rgb_count, true);
|
||||
|
||||
mp_obj_t framebuffer = args[ARG_framebuffer].u_obj;
|
||||
|
|
Loading…
Reference in New Issue