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

Unified Diff: runtime/bin/secure_socket.cc

Issue 11450033: Stop leaking NSS library objects in SecureSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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/secure_socket.cc
diff --git a/runtime/bin/secure_socket.cc b/runtime/bin/secure_socket.cc
index be36dd0cf0aeb409f23026c68a482df671050a2a..1e28e529b0df9e20cbadb7744daaf648d27c9f29 100644
--- a/runtime/bin/secure_socket.cc
+++ b/runtime/bin/secure_socket.cc
@@ -10,6 +10,8 @@
#include <stdio.h>
#include <string.h>
+#include <key.h>
+#include <keyt.h>
#include <nss.h>
#include <pk11pub.h>
#include <prerror.h>
@@ -304,11 +306,11 @@ void SSLFilter::RegisterHandshakeCompleteCallback(Dart_Handle complete) {
}
-void SSLFilter::RegisterBadCertificateCallback(Dart_Handle complete) {
+void SSLFilter::RegisterBadCertificateCallback(Dart_Handle callback) {
if (NULL != bad_certificate_callback_) {
Dart_DeletePersistentHandle(bad_certificate_callback_);
}
- bad_certificate_callback_ = ThrowIfError(Dart_NewPersistentHandle(complete));
+ bad_certificate_callback_ = ThrowIfError(Dart_NewPersistentHandle(callback));
}
@@ -392,6 +394,7 @@ SECStatus SSLFilter::HandleBadCertificate(PRFileDesc* fd) {
certificate->issuerName,
start_epoch_ms,
end_epoch_ms);
+ CERT_DestroyCertificate(certificate);
return accept ? SECSuccess : SECFailure;
}
@@ -427,6 +430,7 @@ void SSLFilter::Connect(const char* host_name,
certificate,
static_cast<void*>(const_cast<char*>(password_)));
if (key == NULL) {
+ CERT_DestroyCertificate(certificate);
if (PR_GetError() == -8177) {
ThrowPRException("Certificate database password incorrect");
} else {
@@ -437,6 +441,8 @@ void SSLFilter::Connect(const char* host_name,
// kt_rsa (key type RSA) is an enum constant from the NSS libraries.
// TODO(whesse): Allow different key types.
status = SSL_ConfigSecureServer(filter_, certificate, key, kt_rsa);
+ CERT_DestroyCertificate(certificate);
+ SECKEY_DestroyPrivateKey(key);
if (status != SECSuccess) {
ThrowPRException("Unsuccessful SSL_ConfigSecureServer call");
}
@@ -510,7 +516,8 @@ void SSLFilter::Destroy() {
if (bad_certificate_callback_ != NULL) {
Dart_DeletePersistentHandle(bad_certificate_callback_);
}
- // TODO(whesse): Free NSS objects here.
+
+ PR_Close(filter_);
}
« 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