~ chicken-core (chicken-5) fc747adfd69887c86038993f8fc65def25981388


commit fc747adfd69887c86038993f8fc65def25981388
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Sat Aug 22 17:58:37 2015 +0200
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Sat Aug 22 19:37:26 2015 +0200

    corrected apply

diff --git a/runtime.c b/runtime.c
index 48845702..984f4ae1 100644
--- a/runtime.c
+++ b/runtime.c
@@ -7147,15 +7147,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