From 1022f9cc35564b216a4bcd7c65e8243c810a0ca9 Mon Sep 17 00:00:00 2001 From: Tom McDermott Date: Mon, 5 Aug 2019 15:15:28 +1000 Subject: py/modstruct: Fix struct.unpack with unaligned offset of native type. With this patch alignment is done relative to the start of the buffer that is being unpacked, not the raw pointer value, as per CPython. Fixes issue #3314. --- extmod/moductypes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'extmod') diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 9b46371f3..d4c7611df 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -299,7 +299,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(uctypes_struct_sizeof_obj, 1, 2, ucty static inline mp_obj_t get_unaligned(uint val_type, byte *p, int big_endian) { char struct_type = big_endian ? '>' : '<'; static const char type2char[16] = "BbHhIiQq------fd"; - return mp_binary_get_val(struct_type, type2char[val_type], &p); + return mp_binary_get_val(struct_type, type2char[val_type], p, &p); } static inline void set_unaligned(uint val_type, byte *p, int big_endian, mp_obj_t val) { -- cgit v1.2.3