diff --git a/src/expr.c b/src/expr.c index 4ff3bd63..5b9fc4ea 100644 --- a/src/expr.c +++ b/src/expr.c @@ -195,6 +195,7 @@ eval_builtin(expr_node *node, Value *locals, Value *ans, int *nonconst) BuiltinFunc *f = node->u.builtin_func; expr_node *kid; int i, j, r; + Value stack_args[10]; /* Check that we have the right number of argumens */ if (node->num_kids < f->minargs) return E_2FEW_ARGS; @@ -207,9 +208,13 @@ eval_builtin(expr_node *node, Value *locals, Value *ans, int *nonconst) info.nargs = node->num_kids; if (info.nargs) { - info.args = malloc(info.nargs * sizeof(Value)); - if (!info.args) { - return E_NO_MEM; + if (info.nargs <= 10) { + info.args = stack_args; + } else { + info.args = malloc(info.nargs * sizeof(Value)); + if (!info.args) { + return E_NO_MEM; + } } } else { info.args = NULL; @@ -223,7 +228,9 @@ eval_builtin(expr_node *node, Value *locals, Value *ans, int *nonconst) for (j=0; jtype == N_SHORT_USER_FUNC) {