Module Name: src Committed By: kre Date: Sun Jul 3 06:30:31 UTC 2022
Modified Files: src/bin/ksh: expr.c Log Message: Fix core dump caused by ksh -c '(i=10; echo $((++-+++i)))' reported by Steffen Nurpmeso (not on a NetBSD list or PR). Seems pointless to fix just one of the bugs in this thing, but this one was easy enough (and stupid enough). (The "i=10" part is unimportant, as is the sub-shell). To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/bin/ksh/expr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/ksh/expr.c diff -u src/bin/ksh/expr.c:1.12 src/bin/ksh/expr.c:1.13 --- src/bin/ksh/expr.c:1.12 Tue May 8 16:37:59 2018 +++ src/bin/ksh/expr.c Sun Jul 3 06:30:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: expr.c,v 1.12 2018/05/08 16:37:59 kamil Exp $ */ +/* $NetBSD: expr.c,v 1.13 2022/07/03 06:30:31 kre Exp $ */ /* * Korn expression evaluation @@ -9,7 +9,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: expr.c,v 1.12 2018/05/08 16:37:59 kamil Exp $"); +__RCSID("$NetBSD: expr.c,v 1.13 2022/07/03 06:30:31 kre Exp $"); #endif @@ -311,6 +311,8 @@ evalexpr(es, prec) token(es); } else if (op == O_PLUSPLUS || op == O_MINUSMINUS) { token(es); + if (es->tok != VAR) + evalerr(es, ET_LVALUE, opinfo[(int) op].name); vl = do_ppmm(es, op, es->val, true); token(es); } else if (op == VAR || op == LIT) {