[PATCH] shell: $(()): hush.c,math.c: fix two usage bugs of new evaluator

Steffen Nurpmeso steffen at sdaoden.eu
Fri Aug 19 17:00:50 UTC 2022


---
 shell/hush.c | 4 +++-
 shell/math.c | 2 --
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/shell/hush.c b/shell/hush.c
index f59bb57b3b..15b36bbe41 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -6843,8 +6843,10 @@ static NOINLINE int expand_one_var(o_string *output, int n,
 				goto empty_result;
 			}
 			len = expand_and_evaluate_arith(exp_word, &errmsg);
-			if (errmsg)
+			if (errmsg) {
+				free(errmsg);
 				goto empty_result;
+			}
 			debug_printf_varexp("len:'%s'=%lld\n", exp_word, (long long)len);
 			debug_printf_varexp("from val:'%s'\n", val);
 			if (len < 0) {
diff --git a/shell/math.c b/shell/math.c
index 8388fdecad..03cddc34a2 100644
--- a/shell/math.c
+++ b/shell/math.c
@@ -254,12 +254,10 @@ static inline u32 a_idec_x(void *resp, char const *cbuf,
 		char const **endptr_or_nil){
 	u32 rv;
 	arith_t res;
-#if ENABLE_FEATURE_SH_MATH_BASE
 	char const *eptr;
 
 	if(endptr_or_nil == NIL)
 		endptr_or_nil = &eptr;
-#endif
 
 	errno = 0;
 	res = strto_arith_t(cbuf, (char**)endptr_or_nil);
-- 
2.37.2


--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)


More information about the busybox mailing list