8000 improving range validation · megacoder/circuitpython@df46636 · GitHub
[go: up one dir, main page]

Skip to content

Commit df46636

Browse files
committed
improving range validation
1 parent 1931b6c commit df46636

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

locale/circuitpython.pot

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3900,10 +3900,6 @@ msgstr ""
39003900
msgid "queue overflow"
39013901
msgstr ""
39023902

3903-
#: shared-bindings/bitmaptools/__init__.c
3904-
msgid "radius must be greater than zero"
3905-
msgstr ""
3906-
39073903
#: py/parse.c
39083904
msgid "raw f-strings are not supported"
39093905
msgstr ""

shared-bindings/bitmaptools/__init__.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -938,15 +938,9 @@ STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_a
938938
int16_t y = args[ARG_y].u_int;
939939
int16_t radius = args[ARG_radius].u_int;
940940

941-
if (x < 0 || x >= destination->width) {
942-
mp_raise_ValueError(translate("out of range of target"));
943-
}
944-
if (y < 0 || y >= destination->height) {
945-
mp_raise_ValueError(translate("out of range of target"));
946-
}
947-
if (radius < 0) {
948-
mp_raise_ValueError(translate("radius must be greater than zero"));
949-
}
941+
mp_arg_validate_int_range(x, 0, destination->width, MP_QSTR_x)
942+
mp_arg_validate_int_range(y, 0, destination->height, MP_QSTR_y)
943+
mp_arg_validate_int_min(radius, 0, MP_QSTR_radius)
950944

951945
common_hal_bitmaptools_draw_circle(destination, x, y, radius, value);
952946

0 commit comments

Comments
 (0)
0