aboutsummaryrefslogtreecommitdiff
path: root/extmod/moductypes.c
diff options
context:
space:
mode:
authorDave Hylands2016-01-03 10:38:36 -0800
committerPaul Sokolovsky2016-01-10 23:31:26 +0200
commit66d0c1052a4623ef91afe4c7b883b7f37a68fa2b (patch)
tree1a0751eedf4e3ed60e78fd6803b842dccd5d9427 /extmod/moductypes.c
parent8175877ad64a631e9ce0f9a5b66782d58ea5f48d (diff)
extmod: Fix uctypes size calculation for bitfields
Diffstat (limited to 'extmod/moductypes.c')
-rw-r--r--extmod/moductypes.c3
1 files changed, 3 insertions, 0 deletions
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;