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

Unified Diff: runtime/bin/security_context.cc

Issue 2923163004: Fixed memory leak in SetTrustedCertificates in SecurityContext (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/security_context.cc
diff --git a/runtime/bin/security_context.cc b/runtime/bin/security_context.cc
index 597f6c151713f80779589e5cfd8df508fa38285e..f394c3bb664b94c71070fb43d724ce1dd03e42ef 100644
--- a/runtime/bin/security_context.cc
+++ b/runtime/bin/security_context.cc
@@ -228,20 +228,22 @@ static int SetTrustedCertificatesBytesPEM(SSL_CTX* context, BIO* bio) {
void SSLCertContext::SetTrustedCertificatesBytes(Dart_Handle cert_bytes,
const char* password) {
- ScopedMemBIO bio(cert_bytes);
- int status = SetTrustedCertificatesBytesPEM(context(), bio.bio());
- if (status == 0) {
- if (SecureSocketUtils::NoPEMStartLine()) {
+ int status = 0;
+ {
+ ScopedMemBIO bio(cert_bytes);
+ status = SetTrustedCertificatesBytesPEM(context(), bio.bio());
+ if (status == 0) {
+ if (SecureSocketUtils::NoPEMStartLine()) {
+ ERR_clear_error();
+ BIO_reset(bio.bio());
+ status =
+ SetTrustedCertificatesBytesPKCS12(context(), bio.bio(), password);
+ }
+ } else {
+ // The PEM file was successfully parsed.
ERR_clear_error();
- BIO_reset(bio.bio());
- status =
- SetTrustedCertificatesBytesPKCS12(context(), bio.bio(), password);
}
- } else {
- // The PEM file was successfully parsed.
- ERR_clear_error();
}
-
SecureSocketUtils::CheckStatus(status, "TlsException",
"Failure trusting builtin roots");
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698