Browse Source

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 <j@w1.fi>
Jouni Malinen 9 years ago
parent
commit
ba54933f63
1 changed files with 1 additions and 2 deletions
  1. 1 2
      src/tls/libtommath.c

+ 1 - 2
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*);