Skip to content

Commit 547ca5a

Browse files
committed
bitmap constructor positive validation
1 parent 5f43a63 commit 547ca5a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

shared-bindings/displayio/Bitmap.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,11 @@
6262
//| ...
6363
STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
6464
mp_arg_check_num(n_args, n_kw, 3, 3, false);
65-
uint32_t width = mp_obj_get_int(all_args[0]);
66-
uint32_t height = mp_obj_get_int(all_args[1]);
67-
uint32_t value_count = mp_obj_get_int(all_args[2]);
65+
uint32_t width = mp_arg_validate_int_min(mp_obj_get_int(all_args[0]), 1, MP_QSTR_width);
66+
uint32_t height = mp_arg_validate_int_min(mp_obj_get_int(all_args[1]), 1, MP_QSTR_height);
67+
uint32_t value_count = mp_arg_validate_int_min(mp_obj_get_int(all_args[2]), 1, MP_QSTR_value_count);
6868
uint32_t bits = 1;
6969

70-
if (value_count == 0) {
71-
mp_raise_ValueError(translate("value_count must be > 0"));
72-
}
7370
while ((value_count - 1) >> bits) {
7471
if (bits < 8) {
7572
bits <<= 1;

0 commit comments

Comments
 (0)