Skip to content

Commit

Permalink
Merge pull request #7867 from RetiredWizard/DispIOSizeValid
Browse files Browse the repository at this point in the history
displayio arg validation tweaking
  • Loading branch information
dhalbert authored Apr 20, 2023
2 parents 7d02bff + a4cb73a commit 81c5a37
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions shared-bindings/displayio/Bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
//| ...
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) {
mp_arg_check_num(n_args, n_kw, 3, 3, false);
uint32_t width = mp_arg_validate_int_range(mp_obj_get_int(all_args[0]), 1, 32767, MP_QSTR_width);
uint32_t height = mp_arg_validate_int_range(mp_obj_get_int(all_args[1]), 1, 32767, MP_QSTR_height);
uint32_t width = mp_arg_validate_int_range(mp_obj_get_int(all_args[0]), 0, 32767, MP_QSTR_width);
uint32_t height = mp_arg_validate_int_range(mp_obj_get_int(all_args[1]), 0, 32767, MP_QSTR_height);
uint32_t value_count = mp_arg_validate_int_range(mp_obj_get_int(all_args[2]), 1, 65535, MP_QSTR_value_count);
uint32_t bits = 1;

Expand Down Expand Up @@ -232,8 +232,8 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg
check_for_deinit(self);

// Check x,y are within self (target) bitmap boundary
int16_t x = mp_arg_validate_int_range(args[ARG_x].u_int, 0, self->width - 1, MP_QSTR_x);
int16_t y = mp_arg_validate_int_range(args[ARG_y].u_int, 0, self->height - 1, MP_QSTR_y);
int16_t x = mp_arg_validate_int_range(args[ARG_x].u_int, 0, MAX(0, self->width - 1), MP_QSTR_x);
int16_t y = mp_arg_validate_int_range(args[ARG_y].u_int, 0, MAX(0, self->height - 1), MP_QSTR_y);

displayio_bitmap_t *source = mp_arg_validate_type(args[ARG_source].u_obj, &displayio_bitmap_type, MP_QSTR_source_bitmap);

Expand All @@ -244,8 +244,8 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg
}

// Check x1,y1,x2,y2 are within source bitmap boundary
int16_t x1 = mp_arg_validate_int_range(args[ARG_x1].u_int, 0, source->width - 1, MP_QSTR_x1);
int16_t y1 = mp_arg_validate_int_range(args[ARG_y1].u_int, 0, source->height - 1, MP_QSTR_y1);
int16_t x1 = mp_arg_validate_int_range(args[ARG_x1].u_int, 0, MAX(0, source->width - 1), MP_QSTR_x1);
int16_t y1 = mp_arg_validate_int_range(args[ARG_y1].u_int, 0, MAX(0, source->height - 1), MP_QSTR_y1);
int16_t x2, y2;
// if x2 or y2 is None, then set as the maximum size of the source bitmap
if (args[ARG_x2].u_obj == mp_const_none) {
Expand Down

0 comments on commit 81c5a37

Please sign in to comment.