Fix coverity CID #1458647 - Use after free in clean_tbuf() which uses ctx->rsa
authorShane Lontis <shane.lontis@oracle.com>
Tue, 11 Aug 2020 06:28:00 +0000 (16:28 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Mon, 24 Aug 2020 01:19:28 +0000 (11:19 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)

providers/implementations/signature/rsa.c

index 1f1aab2c301204ce7c21f11dffa7ac31887fc2f6..7e2de96e839884033b38a4aac6488b631041d9f6 100644 (file)
@@ -832,12 +832,12 @@ static void rsa_freectx(void *vprsactx)
     if (prsactx == NULL)
         return;
 
-    RSA_free(prsactx->rsa);
     EVP_MD_CTX_free(prsactx->mdctx);
     EVP_MD_free(prsactx->md);
     EVP_MD_free(prsactx->mgf1_md);
     OPENSSL_free(prsactx->propq);
     free_tbuf(prsactx);
+    RSA_free(prsactx->rsa);
 
     OPENSSL_clear_free(prsactx, sizeof(*prsactx));
 }