diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-28 00:13:39 -0600 |
|---|---|---|
| committer | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-28 00:13:39 -0600 |
| commit | 0fc285274b7dacbba311bdbd4b4697b7ebcac09c (patch) | |
| tree | 27a25e7f7386a188ac39a1fcd83500a3f7d65017 /web/layouts/partials/git@git.abendless.com:/srv/git | |
| parent | 8ac2777c82668c46c24bb0f3047c1128f9553760 (diff) | |
| download | zash-0fc285274b7dacbba311bdbd4b4697b7ebcac09c.tar.gz | |
fix(parser): save and restore the parser state in run_input
A trap that fires while a command is half parsed, and vi's `v` command,
both run eval_string() from inside the outer parse. The nested
parse_command() points the static arena at its own arena, and freeing
that arena leaves the outer parse allocating from freed memory: silent
corruption in a release build, heap-use-after-free under ASan.
run_input() now brackets its whole body with parser_save()/parser_restore()
on every way out - the normal return, the error unwind and the EXIT
unwind of the recover loop - so any nested eval, present or future, is
safe. in_cond and alias_ended_blank join parser_state because a nested
parse changes them too; the static_assert keeps the snapshot buffer in
step.
Also move here_tail's doc comment back above here_tail.
Tests:
- tests/posix/trap-midtoken.sh: a trap delivered mid-token from a pipe.
It reports heap-use-after-free under `make asan` before the change and
passes after it.
- tests/linux/i-vi-edit.sh: `v` with $VISUAL, $EDITOR and a failing
editor through ptydrive; the edited line runs.
Verified on Linux (clang 20, -O3 -g) with `make check` and ASan+UBSan.
Diffstat (limited to 'web/layouts/partials/git@git.abendless.com:/srv/git')
0 files changed, 0 insertions, 0 deletions
