From 32a68effe0c06cb082741113b2d2714336c5c410 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Thu, 1 Dec 2011 08:43:39 +0900 Subject: [PATCH] Fixing bug off-by-one bug in sexp_apply - stack top was left one higher than on entry to hold the result. This was never noticed before because other functions like eval cleanup the top, and otherwise sexp_apply was never called directly from C code in a loop. --- vm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vm.c b/vm.c index cce96b02..9aecb7a7 100644 --- a/vm.c +++ b/vm.c @@ -1838,8 +1838,9 @@ sexp sexp_apply (sexp ctx, sexp proc, sexp args) { } #endif sexp_gc_release3(ctx); - sexp_context_top(ctx) = top; - return _ARG1; + tmp1 = _ARG1; + sexp_context_top(ctx) = --top; + return tmp1; } sexp sexp_apply1 (sexp ctx, sexp f, sexp x) {