From 3a3647c9f0f77d04a27c4005bc24f3c74aeaac7f Mon Sep 17 00:00:00 2001 From: subtly Date: Wed, 20 May 2015 21:54:35 +0200 Subject: [PATCH] Guard use of m_writeQueue operator[]. --- libp2p/Session.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libp2p/Session.cpp b/libp2p/Session.cpp index 8f395158b..1c037e783 100644 --- a/libp2p/Session.cpp +++ b/libp2p/Session.cpp @@ -319,10 +319,14 @@ void Session::send(bytes&& _msg) void Session::write() { - const bytes& bytes = m_writeQueue[0]; - m_io->writeSingleFramePacket(&bytes, m_writeQueue[0]); + bytes *out; + DEV_GUARDED(x_writeQueue) + { + m_io->writeSingleFramePacket(&m_writeQueue[0], m_writeQueue[0]); + out = &m_writeQueue[0]; + } auto self(shared_from_this()); - ba::async_write(m_socket, ba::buffer(bytes), [this, self](boost::system::error_code ec, std::size_t /*length*/) + ba::async_write(m_socket, ba::buffer(*out), [this, self](boost::system::error_code ec, std::size_t /*length*/) { ThreadContext tc(info().id.abridged()); ThreadContext tc2(info().clientVersion);