Fixed memory leak in SetTrustedCertificates in SecurityContext

BUG=
R=zra@google.com

Review-Url: https://codereview.chromium.org/2923163004 .
This commit is contained in:
Ben Konyi 2017-06-06 14:02:47 -07:00
parent b18c325f68
commit 0e164c043f

View file

@ -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");
}