Skip to content

Commit c615daf

Browse files
committed
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.
1 parent 3f50453 commit c615daf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

shared-module/adafruit_pixelbuf/PixelBuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ STATIC void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t *self, mp_obj_t color,
163163
}
164164

165165
if (mp_obj_is_int(color) || mp_obj_is_float(color)) {
166-
mp_int_t value = mp_obj_is_int(color) ? mp_obj_get_int_truncated(color) : mp_obj_get_float(color);
166+
mp_int_t value = mp_obj_is_int(color) ? mp_obj_get_int_truncated(color) : (mp_int_t)mp_obj_get_float(color);
167167
*r = value >> 16 & 0xff;
168168
*g = (value >> 8) & 0xff;
169169
*b = value & 0xff;

0 commit comments

Comments
 (0)