~ chicken-core (chicken-5) 478c1e3e4cf3c7df3a8e9291fba609fd95e0f578
commit 478c1e3e4cf3c7df3a8e9291fba609fd95e0f578
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:46:01 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 f4605898..31bce9ba 100644
--- a/runtime.c
+++ b/runtime.c
@@ -5085,14 +5085,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