~ chicken-core (chicken-5) 250fdc2e7aeef7461309fa86873f362e6edf29ce


commit 250fdc2e7aeef7461309fa86873f362e6edf29ce
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Sun Oct 4 20:09:19 2015 +1300
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Mon Oct 5 09:55:03 2015 +1300

    Fix (harmless) off-by-one in C_apply_values

diff --git a/runtime.c b/runtime.c
index 9a8e6b4f..26b9b3c0 100644
--- a/runtime.c
+++ b/runtime.c
@@ -7286,8 +7286,7 @@ void C_ccall C_apply_values(C_word c, C_word *av)
   C_word
     /* closure = av[ 0 ] */
     k = av[ 1 ],
-    lst,
-    n;
+    lst, len, n;
 
   if(c != 3) C_bad_argc(c, 3);
 
@@ -7296,16 +7295,17 @@ void C_ccall C_apply_values(C_word c, C_word *av)
   if(lst != C_SCHEME_END_OF_LIST && (C_immediatep(lst) || C_block_header(lst) != C_PAIR_TAG))
     barf(C_BAD_ARGUMENT_TYPE_ERROR, "apply", lst);
 
-  /* Check continuation wether it receives multiple values: */
+  /* Check whether continuation receives multiple values: */
   if(C_block_item(k, 0) == (C_word)values_continuation) {
     C_word *av2, *ptr;
 
-    n = C_unfix(C_u_i_length(lst)) + 1;
+    len = C_unfix(C_u_i_length(lst));
+    n = len + 1;
 
     if (!C_demand(n))
       C_save_and_reclaim((void *)C_apply_values, c, av);
 
-    av2 = C_alloc(n + 1);
+    av2 = C_alloc(n);
     av2[ 0 ] = k;
     ptr = av2 + 1;
     while(!C_immediatep(lst) && C_block_header(lst) == C_PAIR_TAG) {
Trap