~ chicken-core (chicken-5) ea2740f7707a12336955bc1aac86211be339ff44


commit ea2740f7707a12336955bc1aac86211be339ff44
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Tue Jul 14 23:33:33 2015 +0200
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Tue Jul 14 23:38:40 2015 +0200

    corrected apply

diff --git a/runtime.c b/runtime.c
index a20b87e5..b0a7d6fb 100644
--- a/runtime.c
+++ b/runtime.c
@@ -5970,15 +5970,18 @@ void C_ccall C_apply(C_word c, C_word *av)
     ++m;
   }
 
-  C_temporary_stack -= n;
+  if(c > 4) {
+    C_temporary_stack -= n - 1;
 
-  if(C_temporary_stack < C_temporary_stack_limit)
-    barf(C_TOO_MANY_PARAMETERS_ERROR, "apply");
+    if(C_temporary_stack < C_temporary_stack_limit)
+      barf(C_TOO_MANY_PARAMETERS_ERROR, "apply");
 
-  C_memcpy(C_temporary_stack, av + 3, n * sizeof(C_word));
-  --m;
+    C_memcpy(C_temporary_stack, av + 3, n * sizeof(C_word));
+  }
 
-  ((C_proc)(void *)C_block_item(fn, 0))(m, C_temporary_stack);
+  C_save(k);
+  C_save(fn);
+  ((C_proc)(void *)C_block_item(fn, 0))(m + 1, C_temporary_stack);
 }
 
 
Trap