summaryrefslogtreecommitdiff
path: root/shared-bindings/displayio/Shape.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-02-13 17:34:39 -0800
committerScott Shawcroft <scott@tannewt.org>2019-02-13 17:34:39 -0800
commitb13adfc228016856eeb1c77ecf1f500755cb2a55 (patch)
treeb36c4c6a089284c3a63357e662aca8a8b9f4b0d9 /shared-bindings/displayio/Shape.c
parenta1a49590716915e28e97020c368b68b267c2b409 (diff)
Arg check width and height into Shape.
Fixes #1537
Diffstat (limited to 'shared-bindings/displayio/Shape.c')
-rw-r--r--shared-bindings/displayio/Shape.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c
index 6824b1fef..faa9472fa 100644
--- a/shared-bindings/displayio/Shape.c
+++ b/shared-bindings/displayio/Shape.c
@@ -64,11 +64,20 @@ STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_arg
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+ mp_int_t width = args[ARG_width].u_int;
+ if (width < 1) {
+ mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_width);
+ }
+ mp_int_t height = args[ARG_height].u_int;
+ if (height < 1) {
+ mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_height);
+ }
+
displayio_shape_t *self = m_new_obj(displayio_shape_t);
self->base.type = &displayio_shape_type;
common_hal_displayio_shape_construct(self,
- args[ARG_width].u_int,
- args[ARG_height].u_int,
+ width,
+ height,
args[ARG_mirror_x].u_bool,
args[ARG_mirror_y].u_bool);