Skip to content

Commit 03cddb6

Browse files
committed
Fix memory leaks in RSAKeyPair
1 parent ebca9fd commit 03cddb6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.daily_canary

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Flime is a tat circle. Flunchtime toubly so.
1+
A tribute to a witty line.

src/tls/rsa_key_pair.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ namespace tls
213213
EVP_PKEY_encrypt(ctx, output.data(), &olen, input, input_size));
214214

215215
output.resize(olen);
216+
EVP_PKEY_CTX_free(ctx);
216217
return output;
217218
}
218219

@@ -418,7 +419,9 @@ namespace tls
418419
EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, openssl_label, label_size);
419420
}
420421
else
422+
{
421423
EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, NULL, 0);
424+
}
422425

423426
size_t olen;
424427
OPENSSL_CHECK1(
@@ -429,6 +432,7 @@ namespace tls
429432
ctx, output.data(), &olen, input.data(), input.size()));
430433

431434
output.resize(olen);
435+
EVP_PKEY_CTX_free(ctx);
432436
return output;
433437
}
434438
};
@@ -445,7 +449,7 @@ namespace tls
445449
size_t public_key_size = RSAKeyPair::default_public_key_size,
446450
size_t public_exponent = RSAKeyPair::default_public_exponent)
447451
{
448-
return RSAKeyPairPtr(new RSAKeyPair(public_key_size, public_exponent));
452+
return std::make_shared<RSAKeyPair>(public_key_size, public_exponent);
449453
}
450454

451455
/**

0 commit comments

Comments
 (0)