Explicitly cast float to mp_int_t

Not sure why this is necessary, but it prevents an off-by-one error in
some (rare?) circumstances.
This commit is contained in:
George Waters 2021-12-17 16:23:58 -05:00
parent 3f50453dd0
commit c615daff30
No known key found for this signature in database
GPG Key ID: D993F8B1CC21DB25
1 changed files with 1 additions and 1 deletions

View File

@ -163,7 +163,7 @@ STATIC void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t *self, mp_obj_t color,
}
if (mp_obj_is_int(color) || mp_obj_is_float(color)) {
mp_int_t value = mp_obj_is_int(color) ? mp_obj_get_int_truncated(color) : mp_obj_get_float(color);
mp_int_t value = mp_obj_is_int(color) ? mp_obj_get_int_truncated(color) : (mp_int_t)mp_obj_get_float(color);
*r = value >> 16 & 0xff;
*g = (value >> 8) & 0xff;
*b = value & 0xff;