diff options
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 1daa33338..0d4a45f6b 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -206,7 +206,8 @@ STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, byte* end_p, siz memset(p + to_copy, 0, sz - to_copy); p += sz; } else { - while (sz--) { + // If we run out of args then we just finish; CPython would raise struct.error + while (sz-- && i < n_args) { mp_binary_set_val(fmt_type, *fmt, args[i++], &p); } } |