chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] Ensure va_end() is always called in C_a_i_


From: Kooda
Subject: Re: [Chicken-hackers] [PATCH] Ensure va_end() is always called in C_a_i_string()
Date: Fri, 20 Jan 2017 16:28:23 +0100

On Thu, 19 Jan 2017 22:16:20 +1300
Evan Hanson <address@hidden> wrote:

> Previously, the call to va_end() would be skipped when this procedure
> was given invalid arguments (and continued to `barf` a result).
> ---
>  runtime.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> 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;
>  }
>  

Looks fine, pushed!

I’m curious though: how did you catch this?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]