Increment the reference count of sessions inside the lock.

Otherwise another thread may cause the session to be destroyed first.

Change-Id: I2084a28ece11540e1b8f289553161d99395e2d1f
Reviewed-on: https://boringssl-review.googlesource.com/5231
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2015-06-16 15:59:03 -04:00 committed by Adam Langley
parent d98452d2db
commit bed63548d1

View File

@ -420,11 +420,10 @@ int ssl_get_prev_session(SSL *s, const struct ssl_early_callback_ctx *ctx) {
CRYPTO_MUTEX_lock_read(&s->initial_ctx->lock);
ret = lh_SSL_SESSION_retrieve(s->initial_ctx->sessions, &data);
CRYPTO_MUTEX_unlock(&s->initial_ctx->lock);
if (ret != NULL) {
SSL_SESSION_up_ref(ret);
}
CRYPTO_MUTEX_unlock(&s->initial_ctx->lock);
}
if (try_session_cache && ret == NULL &&