Skip to content

Commit

Permalink
multiplexed socket: avoid use-after-free
Browse files Browse the repository at this point in the history
Change-Id: I0c093ea4e1834866fd08abb30d51d5043fe1f455
  • Loading branch information
aberaud committed Jan 17, 2025
1 parent d16f816 commit f0f834d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/multiplexed_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,15 @@ class MultiplexedSocket::Impl
void
MultiplexedSocket::Impl::eventLoop()
{
endpoint->setOnStateChange([this](tls::TlsSessionState state) {
if (state == tls::TlsSessionState::SHUTDOWN && !isShutdown_) {
if (logger_)
logger_->debug("Tls endpoint is down, shutdown multiplexed socket");
shutdown();
endpoint->setOnStateChange([w = parent_.weak_from_this()](tls::TlsSessionState state) {
auto ssock = w.lock();
if (!ssock)
return false;
auto& this_ = *ssock->pimpl_;
if (state == tls::TlsSessionState::SHUTDOWN && !this_.isShutdown_) {
if (this_.logger_)
this_.logger_->debug("Tls endpoint is down, shutdown multiplexed socket");
this_.shutdown();
return false;
}
return true;
Expand Down

0 comments on commit f0f834d

Please sign in to comment.