Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: crypto/signature_creator_openssl.cc

Issue 392653005: Fix memory leaks when calling EVP_PKEY_get1_RSA. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto/rsa_private_key_openssl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/signature_creator_openssl.cc
diff --git a/crypto/signature_creator_openssl.cc b/crypto/signature_creator_openssl.cc
index e46d3d002c1b24eddc94729290d6c9a3c50fb51f..3c8f532cbebc2a31aaf26989fa9b4c622ae337fa 100644
--- a/crypto/signature_creator_openssl.cc
+++ b/crypto/signature_creator_openssl.cc
@@ -12,6 +12,7 @@
#include "base/stl_util.h"
#include "crypto/openssl_util.h"
#include "crypto/rsa_private_key.h"
+#include "crypto/scoped_openssl_types.h"
namespace crypto {
@@ -30,14 +31,14 @@ bool SignatureCreator::Sign(RSAPrivateKey* key,
const uint8* data,
int data_len,
std::vector<uint8>* signature) {
- RSA* rsa_key = EVP_PKEY_get1_RSA(key->key());
+ ScopedRSA rsa_key(EVP_PKEY_get1_RSA(key->key()));
if (!rsa_key)
return false;
- signature->resize(RSA_size(rsa_key));
+ signature->resize(RSA_size(rsa_key.get()));
unsigned int len = 0;
bool success = RSA_sign(NID_sha1, data, data_len, vector_as_array(signature),
- &len, rsa_key);
+ &len, rsa_key.get());
if (!success) {
signature->clear();
return false;
« no previous file with comments | « crypto/rsa_private_key_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698