From: Maks Naumov Date: Sat, 2 May 2015 20:21:37 +0000 (+0300) Subject: libtommath: Fix check mp_init_multi() result X-Git-Tag: hostap_2_5~765 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74d912f134984fac1a5d95ed001af1564a1191fc;p=thirdparty%2Fhostap.git libtommath: Fix check mp_init_multi() result If the mp_init_multi() call had failed due to memory allocation failure, mp_div() would have returned 1 instead of MP_MEM (-2). It looks like all callers are checking the return value against MP_OKAY instead of <1 (etc.), so this does not seem to result in difference in behavior. Anyway, it's best to fix the mp_div() return value for the MP_MEM error case to avoid unexpected behavior. Signed-off-by: Maks Naumov --- diff --git a/src/tls/libtommath.c b/src/tls/libtommath.c index 3fb8fbed2..251133e71 100644 --- a/src/tls/libtommath.c +++ b/src/tls/libtommath.c @@ -1631,7 +1631,7 @@ static int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d) } /* init our temps */ - if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL) != MP_OKAY)) { + if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL)) != MP_OKAY) { return res; }