mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-05 20:26:39 +02:00
fixing segfault when applying a first-class opcode to the wrong # of arguments
This commit is contained in:
parent
d6e279eccd
commit
178cf109bd
1 changed files with 7 additions and 2 deletions
9
eval.c
9
eval.c
|
@ -1141,8 +1141,13 @@ static sexp make_param_list (sexp ctx, sexp_uint_t i) {
|
|||
static sexp make_opcode_procedure (sexp ctx, sexp op, sexp_uint_t i) {
|
||||
sexp ls, bc, res, env;
|
||||
sexp_gc_var5(params, ref, refs, lambda, ctx2);
|
||||
if (i == sexp_opcode_num_args(op) && sexp_opcode_proc(op))
|
||||
return sexp_opcode_proc(op); /* return before preserving */
|
||||
if (i == sexp_opcode_num_args(op)) { /* return before preserving */
|
||||
if (sexp_opcode_proc(op)) return sexp_opcode_proc(op);
|
||||
} else if (i < sexp_opcode_num_args(op)) {
|
||||
return sexp_compile_error(ctx, "not enough args for opcode", op);
|
||||
} else if (! sexp_opcode_variadic_p(op)) { /* i > num_args */
|
||||
return sexp_compile_error(ctx, "too many args for opcode", op);
|
||||
}
|
||||
sexp_gc_preserve5(ctx, params, ref, refs, lambda, ctx2);
|
||||
params = make_param_list(ctx, i);
|
||||
lambda = sexp_make_lambda(ctx, params);
|
||||
|
|
Loading…
Add table
Reference in a new issue