From ba54933f63b6ececde3e1a85bb5149fd59b22f6e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 23 Jun 2015 20:39:08 +0300 Subject: [PATCH] libtommath: Fix mp_init_multi() stdarg use on error path Previously, it would have been possible for va_end(args) to be called twice in case mp_init() fails. While that may not cause issues on number of platforms, that is not how va_start()/va_end() are supposed to be used. Fix this by returning from the function without using va_end() twice on the same va_list args. Signed-off-by: Jouni Malinen --- src/tls/libtommath.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tls/libtommath.c b/src/tls/libtommath.c index 251133e71..8bc824f20 100644 --- a/src/tls/libtommath.c +++ b/src/tls/libtommath.c @@ -1472,8 +1472,7 @@ static int mp_init_multi(mp_int *mp, ...) cur_arg = va_arg(clean_args, mp_int*); } va_end(clean_args); - res = MP_MEM; - break; + return MP_MEM; } n++; cur_arg = va_arg(args, mp_int*);