diff options
| author | kre <kre@NetBSD.org> | 2022-07-03 06:30:31 +0000 |
|---|---|---|
| committer | kre <kre@NetBSD.org> | 2022-07-03 06:30:31 +0000 |
| commit | dc257ae71c33810d9a2c42a8dce7565dbe7cdb5f (patch) | |
| tree | 106e121c35e622f2389a973023a8631727e85b21 /bin | |
| parent | e06b2320ea24b43035011363b0de1f69e729a352 (diff) | |
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).
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/ksh/expr.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/ksh/expr.c b/bin/ksh/expr.c index 5d85b521fe4..71e54091b44 100644 --- a/bin/ksh/expr.c +++ b/bin/ksh/expr.c @@ -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) { |
