~ chicken-core (chicken-5) b3c7062087c385d237905a5064906e3c141e5c1e


commit b3c7062087c385d237905a5064906e3c141e5c1e
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Thu Jan 19 22:16:20 2017 +1300
Commit:     Kooda <kooda@upyum.com>
CommitDate: Fri Jan 20 16:20:00 2017 +0100

    Ensure va_end() is always called in C_a_i_string()
    
    Previously, the call to va_end() would be skipped when this procedure
    was given invalid arguments (and continued to `barf` a result).
    
    Signed-off-by: Kooda <kooda@upyum.com>

diff --git a/runtime.c b/runtime.c
index 78f2f9b6..40fd368f 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4863,14 +4863,16 @@ C_word C_a_i_string(C_word **a, int c, ...)
   p = (char *)C_data_pointer(s);
   va_start(v, c);
 
-  while(c--) {
+  for(; c; c--) {
     x = va_arg(v, C_word);
 
     if((x & C_IMMEDIATE_TYPE_BITS) == C_CHARACTER_BITS)
       *(p++) = C_character_code(x);
-    else barf(C_BAD_ARGUMENT_TYPE_ERROR, "string", x);
+    else break;
   }
 
+  va_end(v);
+  if (c) barf(C_BAD_ARGUMENT_TYPE_ERROR, "string", x);
   return s;
 }
 
Trap