]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
rsa: fix coverity 1463571: explicit null dereference
authorPauli <ppzgs1@gmail.com>
Fri, 19 Mar 2021 00:17:11 +0000 (10:17 +1000)
committerPauli <pauli@openssl.org>
Thu, 25 Mar 2021 22:44:04 +0000 (08:44 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14618)

providers/implementations/keymgmt/rsa_kmgmt.c

index 394f3836dd71434de36ba3d42051372839386594..eac3843884979628733755942235c6ff728ee4ef 100644 (file)
@@ -435,16 +435,15 @@ static void *gen_init(void *provctx, int selection, int rsa_type,
             || !BN_set_word(gctx->pub_exp, RSA_F4)) {
             BN_free(gctx->pub_exp);
             OPENSSL_free(gctx);
-            gctx = NULL;
-        } else {
-            gctx->nbits = 2048;
-            gctx->primes = RSA_DEFAULT_PRIME_NUM;
-            gctx->rsa_type = rsa_type;
+            return NULL;
         }
+        gctx->nbits = 2048;
+        gctx->primes = RSA_DEFAULT_PRIME_NUM;
+        gctx->rsa_type = rsa_type;
     }
     if (!rsa_gen_set_params(gctx, params)) {
         OPENSSL_free(gctx);
-        gctx = NULL;
+        return NULL;
     }
     return gctx;
 }