From 66d0c1052a4623ef91afe4c7b883b7f37a68fa2b Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Sun, 3 Jan 2016 10:38:36 -0800 Subject: extmod: Fix uctypes size calculation for bitfields --- extmod/moductypes.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'extmod') diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 6e4a94b60..48cbfad52 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -230,6 +230,9 @@ STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, mp_uint_ mp_uint_t offset = MP_OBJ_SMALL_INT_VALUE(v); mp_uint_t val_type = GET_TYPE(offset, VAL_TYPE_BITS); offset &= VALUE_MASK(VAL_TYPE_BITS); + if (val_type >= BFUINT8 && val_type <= BFINT32) { + offset &= (1 << OFFSET_BITS) - 1; + } mp_uint_t s = uctypes_struct_scalar_size(val_type); if (s > *max_field_size) { *max_field_size = s; -- cgit v1.2.3