diff --git a/ssl/test/bssl_shim.cc b/ssl/test/bssl_shim.cc index 67b74b4b..175e5bf6 100644 --- a/ssl/test/bssl_shim.cc +++ b/ssl/test/bssl_shim.cc @@ -121,9 +121,10 @@ static const TestConfig *GetConfigPtr(const SSL *ssl) { return (const TestConfig *)SSL_get_ex_data(ssl, g_config_index); } -static bool SetTestState(SSL *ssl, std::unique_ptr async) { - if (SSL_set_ex_data(ssl, g_state_index, (void *)async.get()) == 1) { - async.release(); +static bool SetTestState(SSL *ssl, std::unique_ptr state) { + // |SSL_set_ex_data| takes ownership of |state| only on success. + if (SSL_set_ex_data(ssl, g_state_index, state.get()) == 1) { + state.release(); return true; } return false;