Fix a memory leak in an error path
[openssl.git] / crypto / rsa / rsa_mp.c
index 8ff4b636256d9e01f4ce7d56b5a78c6c09fe2446..7e38179b97d4d06224e4713f11310607d04ac13a 100644 (file)
@@ -51,6 +51,7 @@ RSA_PRIME_INFO *rsa_multip_info_new(void)
     BN_free(pinfo->d);
     BN_free(pinfo->t);
     BN_free(pinfo->pp);
+    OPENSSL_free(pinfo);
     return NULL;
 }
 
@@ -105,5 +106,8 @@ int rsa_multip_cap(int bits)
     else if (bits < 8192)
         cap = 4;
 
+    if (cap > RSA_MAX_PRIME_NUM)
+        cap = RSA_MAX_PRIME_NUM;
+
     return cap;
 }