diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-19 10:22:15 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-19 10:22:15 +0200 |
commit | db0e886735112110183fe3e4f1dea7c0f31a36c9 (patch) | |
tree | 5f4704b391afc2dd1fd9bf6558ce6fe02a50c80a | |
parent | a165098922ddbfbca3579538f50b44002ab0fae7 (diff) | |
download | busybox-w32-db0e886735112110183fe3e4f1dea7c0f31a36c9.tar.gz busybox-w32-db0e886735112110183fe3e4f1dea7c0f31a36c9.tar.bz2 busybox-w32-db0e886735112110183fe3e4f1dea7c0f31a36c9.zip |
shell/math: $((1?)) has one-too-small opstack, fix this
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/math.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/shell/math.c b/shell/math.c index d9986335a..0cf963731 100644 --- a/shell/math.c +++ b/shell/math.c | |||
@@ -114,7 +114,7 @@ | |||
114 | #include "libbb.h" | 114 | #include "libbb.h" |
115 | #include "math.h" | 115 | #include "math.h" |
116 | 116 | ||
117 | #if 1 | 117 | #if 0 |
118 | # define dbg(...) ((void)0) | 118 | # define dbg(...) ((void)0) |
119 | #else | 119 | #else |
120 | # define dbg(...) bb_error_msg(__VA_ARGS__) | 120 | # define dbg(...) bb_error_msg(__VA_ARGS__) |
@@ -631,6 +631,7 @@ evaluate_string(arith_state_t *math_state, const char *expr) | |||
631 | * (IOW: more than one slot), but its second slot (LPAREN) | 631 | * (IOW: more than one slot), but its second slot (LPAREN) |
632 | * is popped off when ":" is reached. | 632 | * is popped off when ":" is reached. |
633 | */ | 633 | */ |
634 | expr_len++; /* +1 for 1st LPAREN. See what $((1?)) pushes to opstack */ | ||
634 | opstackptr = opstack = alloca(expr_len * sizeof(opstack[0])); | 635 | opstackptr = opstack = alloca(expr_len * sizeof(opstack[0])); |
635 | /* There can be no more than (expr_len/2 + 1) | 636 | /* There can be no more than (expr_len/2 + 1) |
636 | * integers/names in any given correct or incorrect expression. | 637 | * integers/names in any given correct or incorrect expression. |