From 5ca7c325e322cd2610e6e932f2529f176d531947 Mon Sep 17 00:00:00 2001 From: Johnothan King Date: Wed, 17 Mar 2021 01:46:21 -0700 Subject: [PATCH] tests/pty.sh: Add a regression test for a ksh93r crash (re: 129614b9) (#227) In ksh93r a crash can occur after switching from emacs mode to vi mode[*]: $ ENV=/./dev/null ksh2006 -o emacs $ echo ${.sh.version} Version M 1993-12-28 r $ set -o vi $ # This triggers the memory fault Commit 129614b9 added the OpenSUSE patch for this crash. This commit adds the regression test for it. [*]: https://bugzilla.opensuse.org/show_bug.cgi?id=179917 --- src/cmd/ksh93/tests/pty.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/cmd/ksh93/tests/pty.sh b/src/cmd/ksh93/tests/pty.sh index d35f8d14e..dbbd29b0b 100755 --- a/src/cmd/ksh93/tests/pty.sh +++ b/src/cmd/ksh93/tests/pty.sh @@ -733,5 +733,22 @@ w echo "Exit status is: $?" u Exit status is: 1 ! +((SHOPT_ESH)) && ((SHOPT_VSH)) && tst $LINENO <<"!" +L crash after switching from emacs to vi mode + +# In ksh93r using the vi 'r' command after switching from emacs mode could +# trigger a memory fault: https://bugzilla.opensuse.org/show_bug.cgi?id=179917 + +d 15 +w exec $SHELL -o emacs +u emacs +w set -o vi +u set -o vi +c \Erri +w echo Success +u echo +r ^Success\r?\n$ +! + # ====== exit $((Errors<125?Errors:125))