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>
This commit is contained in:
Jouni Malinen 2015-06-23 20:39:08 +03:00
parent f6332b0be1
commit ba54933f63

View 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*);