]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
libtommath: Fix mp_init_multi() stdarg use on error path
authorJouni Malinen <j@w1.fi>
Tue, 23 Jun 2015 17:39:08 +0000 (20:39 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 23 Jun 2015 17:39:08 +0000 (20:39 +0300)
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 <j@w1.fi>
src/tls/libtommath.c

index 251133e711285a6894fc4c9cc30e31bbc723c676..8bc824f20dcdc4a7932686e39e8de63fb77f2eba 100644 (file)
@@ -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*);