Switch some easy SSL fields to UniquePtr.
Change-Id: I982ecda5a19187708b15e8572e6d0000c22ed87c
Reviewed-on: https://boringssl-review.googlesource.com/29590
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/ssl_session.cc b/ssl/ssl_session.cc
index 379cea7..d5af8aa 100644
--- a/ssl/ssl_session.cc
+++ b/ssl/ssl_session.cc
@@ -478,7 +478,7 @@
// Initialize HMAC and cipher contexts. If callback present it does all the
// work otherwise use generated values from parent ctx.
- SSL_CTX *tctx = hs->ssl->session_ctx;
+ SSL_CTX *tctx = hs->ssl->session_ctx.get();
uint8_t iv[EVP_MAX_IV_LENGTH];
uint8_t key_name[16];
if (tctx->tlsext_ticket_key_cb != NULL) {
@@ -696,13 +696,13 @@
// Add the externally cached session to the internal cache if necessary.
if (!(ssl->session_ctx->session_cache_mode &
SSL_SESS_CACHE_NO_INTERNAL_STORE)) {
- SSL_CTX_add_session(ssl->session_ctx, session.get());
+ SSL_CTX_add_session(ssl->session_ctx.get(), session.get());
}
}
if (session && !ssl_session_is_time_valid(ssl, session.get())) {
// The session was from the cache, so remove it.
- SSL_CTX_remove_session(ssl->session_ctx, session.get());
+ SSL_CTX_remove_session(ssl->session_ctx.get(), session.get());
session.reset();
}
@@ -788,15 +788,11 @@
}
void ssl_set_session(SSL *ssl, SSL_SESSION *session) {
- if (ssl->session == session) {
+ if (ssl->session.get() == session) {
return;
}
- SSL_SESSION_free(ssl->session);
- ssl->session = session;
- if (session != NULL) {
- SSL_SESSION_up_ref(session);
- }
+ ssl->session = UpRef(session);
}
// locked by SSL_CTX in the calling function
@@ -1070,7 +1066,7 @@
if (hs->new_session) {
return hs->new_session.get();
}
- return ssl->session;
+ return ssl->session.get();
}
SSL_SESSION *SSL_get1_session(SSL *ssl) {