fix error found by coverity: check if ctx is != NULL before calling BN_CTX_end()
[openssl.git] / crypto / rsa / rsa_gen.c
index 383d6095f57c989522d1aa6ec860d7f8a7f10173..742f8b18e5addabe76b5f67f07845eeac0b9a89a 100644 (file)
@@ -183,8 +183,11 @@ err:
                RSAerr(RSA_F_RSA_BUILTIN_KEYGEN,ERR_LIB_BN);
                ok=0;
                }
-       BN_CTX_end(ctx);
-       BN_CTX_free(ctx);
+       if (ctx != NULL)
+               {
+               BN_CTX_end(ctx);
+               BN_CTX_free(ctx);
+               }
 
        return ok;
        }