diff options
| author | David Lechner <david@pybricks.com> | 2022-08-05 18:52:13 -0500 |
|---|---|---|
| committer | David Lechner <david@pybricks.com> | 2022-08-06 11:32:58 -0500 |
| commit | 6baeded32236feb9ba57ce78477fd1ee80fb4697 (patch) | |
| tree | 2b61e0bb8658ebf0ab53aaf8b3ef575a07bfc7f0 /tests | |
| parent | 9dfabcd6d3d080aced888e8474e921f11dc979bb (diff) | |
py/runtime: Fix crash in star arg unpacking.
The reallocation trigger for unpacking star args with unknown length
did not take into account the number of fixed args remaining. So it was
possible that the unpacked iterators could take up exactly the memory
allocated then nothing would be left for fixed args after the star args.
This causes a segfault crash.
This is fixed by taking into account the remaining number of fixed args
in the check to decide whether to realloc yet or not.
Signed-off-by: David Lechner <david@pybricks.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basics/fun_callstardblstar.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/basics/fun_callstardblstar.py b/tests/basics/fun_callstardblstar.py index f395df333..c08e46f66 100644 --- a/tests/basics/fun_callstardblstar.py +++ b/tests/basics/fun_callstardblstar.py @@ -37,3 +37,7 @@ f2(*iter(range(4)), **{'a': 1}) # case where *args is not a tuple/list and takes up most of the memory allocated for **kwargs f2(*iter(range(100)), **{str(i): i for i in range(100)}) + +# regression test - iterable with unknown len() was exactly using preallocated +# memory causing args 4 and 5 to overflow the allocated arg array +print(1, *iter((1, 2, 3)), *iter((1, 2, 3)), 4, 5, sep=",") |
