<feed xmlns='http://www.w3.org/2005/Atom'>
<title>zash.git/tests/linux/i-vi-edit.exp, branch main</title>
<subtitle>Fast Almquist-family POSIX shell for z/OS UNIX with bundled libedit</subtitle>
<id>https://git.abendless.com/zash.git/atom?h=main</id>
<link rel='self' href='https://git.abendless.com/zash.git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/'/>
<updated>2026-11-28T06:13:39Z</updated>
<entry>
<title>fix(parser): save and restore the parser state in run_input</title>
<updated>2026-11-28T06:13:39Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T06:13:39Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=0fc285274b7dacbba311bdbd4b4697b7ebcac09c'/>
<id>urn:sha1:0fc285274b7dacbba311bdbd4b4697b7ebcac09c</id>
<content type='text'>
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.
</content>
</entry>
</feed>
