]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dragonfly: Fix a memory leak on error path
authorJouni Malinen <jouni@codeaurora.org>
Wed, 8 May 2019 15:55:57 +0000 (18:55 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 8 May 2019 15:55:57 +0000 (18:55 +0300)
This is mostly a theoretical case, but since crypto_bignum_rand() could
fail, need to free the allocated struct crypto_bignum *tmp in such a
case.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/common/dragonfly.c

index 10d968ac4e259b5078141c0902b5568b60fb5a89..e98bce68233a164a1317e300a00955c944b81d33 100644 (file)
@@ -40,8 +40,10 @@ int dragonfly_get_random_qr_qnr(const struct crypto_bignum *prime,
                int res;
 
                tmp = crypto_bignum_init();
-               if (!tmp || crypto_bignum_rand(tmp, prime) < 0)
+               if (!tmp || crypto_bignum_rand(tmp, prime) < 0) {
+                       crypto_bignum_deinit(tmp, 0);
                        break;
+               }
 
                res = crypto_bignum_legendre(tmp, prime);
                if (res == 1 && !(*qr))