py/modstruct: Fix struct.pack_into with unaligned offset of native type.
Following the same fix for unpack.
diff --git a/py/modstruct.c b/py/modstruct.c
index 957e491..3e7d90e 100644
--- a/py/modstruct.c
+++ b/py/modstruct.c
@@ -180,6 +180,7 @@
const char *fmt = mp_obj_str_get_str(fmt_in);
char fmt_type = get_fmt_type(&fmt);
+ byte *p_base = p;
size_t i;
for (i = 0; i < n_args;) {
mp_uint_t cnt = 1;
@@ -204,7 +205,7 @@
} else {
// If we run out of args then we just finish; CPython would raise struct.error
while (cnt-- && i < n_args) {
- mp_binary_set_val(fmt_type, *fmt, args[i++], &p);
+ mp_binary_set_val(fmt_type, *fmt, args[i++], p_base, &p);
}
}
fmt++;