diff options
author | Damien George <damien.p.george@gmail.com> | 2019-09-02 12:57:51 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-09-02 13:14:16 +1000 |
commit | 24c3e9b283da26093ca653fc6b441042fedec135 (patch) | |
tree | 430cf3923afccc874902bebecb79f5b22572777c /py/modstruct.c | |
parent | 1022f9cc35564b216a4bcd7c65e8243c810a0ca9 (diff) |
py/modstruct: Fix struct.pack_into with unaligned offset of native type.
Following the same fix for unpack.
Diffstat (limited to 'py/modstruct.c')
-rw-r--r-- | py/modstruct.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/py/modstruct.c b/py/modstruct.c index 957e4917b..3e7d90ec1 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -180,6 +180,7 @@ STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, c 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 @@ STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, c } 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++; |