fix: remove unneeded EVP_PKEY_new() (causes memory leak)

This commit is contained in:
SASANO Takayoshi 2026-05-18 23:31:39 +09:00 committed by Chris Rizzitello
parent 051464e7fd
commit 53903016b1

View file

@ -66,14 +66,12 @@ void generatePemSelfSignedCert(const QString &path, int keyLength)
{
auto expirationDays = 365;
auto *privateKey = EVP_PKEY_new();
auto *privateKey = EVP_RSA_gen(keyLength);
if (!privateKey) {
throw std::runtime_error("could not allocate private key for certificate");
throw std::runtime_error("failed to generate a " + std::to_string(keyLength) + "bit key for certificate");
}
auto privateKeyFree = finally([privateKey]() { EVP_PKEY_free(privateKey); });
privateKey = EVP_RSA_gen(keyLength);
auto *cert = X509_new();
if (!cert) {
throw std::runtime_error("could not allocate certificate");