mirror of
https://github.com/boostorg/asio.git
synced 2026-01-27 18:42:07 +00:00
Add a workaround for MSVC secure iterator problem where allowing the
destruction of an iterator to an already-destroyed string object results in a program crash. Revert previous change to destroy buffers prior to invoking the handler since it didn't fix the problem and wasn't cleaning up all copies of the buffers anyway. [SVN r41059]
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# if defined(_HAS_ITERATOR_DEBUGGING)
|
||||
# if defined(_HAS_ITERATOR_DEBUGGING) && (_HAS_ITERATOR_DEBUGGING != 0)
|
||||
# if !defined(BOOST_ASIO_DISABLE_BUFFER_DEBUGGING)
|
||||
# define BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
|
||||
# endif // !defined(BOOST_ASIO_DISABLE_BUFFER_DEBUGGING)
|
||||
@@ -391,6 +391,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~buffer_debug_check()
|
||||
{
|
||||
iter_ = Iterator();
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
*iter_;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <algorithm>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/buffer.hpp>
|
||||
@@ -140,25 +139,23 @@ namespace detail
|
||||
std::size_t bytes_transferred)
|
||||
{
|
||||
total_transferred_ += bytes_transferred;
|
||||
buffers_->consume(bytes_transferred);
|
||||
if ((*completion_condition_)(ec, total_transferred_)
|
||||
|| buffers_->begin() == buffers_->end())
|
||||
buffers_.consume(bytes_transferred);
|
||||
if (completion_condition_(ec, total_transferred_)
|
||||
|| buffers_.begin() == buffers_.end())
|
||||
{
|
||||
buffers_.reset();
|
||||
completion_condition_.reset();
|
||||
handler_(ec, total_transferred_);
|
||||
}
|
||||
else
|
||||
{
|
||||
stream_.async_read_some(*buffers_, *this);
|
||||
stream_.async_read_some(buffers_, *this);
|
||||
}
|
||||
}
|
||||
|
||||
//private:
|
||||
AsyncReadStream& stream_;
|
||||
boost::optional<buffers_type> buffers_;
|
||||
buffers_type buffers_;
|
||||
std::size_t total_transferred_;
|
||||
boost::optional<CompletionCondition> completion_condition_;
|
||||
CompletionCondition completion_condition_;
|
||||
ReadHandler handler_;
|
||||
};
|
||||
|
||||
@@ -239,9 +236,8 @@ namespace detail
|
||||
total_transferred_ += bytes_transferred;
|
||||
streambuf_.commit(bytes_transferred);
|
||||
if (streambuf_.size() == streambuf_.max_size()
|
||||
|| (*completion_condition_)(ec, total_transferred_))
|
||||
|| completion_condition_(ec, total_transferred_))
|
||||
{
|
||||
completion_condition_.reset();
|
||||
handler_(ec, total_transferred_);
|
||||
}
|
||||
else
|
||||
@@ -256,7 +252,7 @@ namespace detail
|
||||
AsyncReadStream& stream_;
|
||||
boost::asio::basic_streambuf<Allocator>& streambuf_;
|
||||
std::size_t total_transferred_;
|
||||
boost::optional<CompletionCondition> completion_condition_;
|
||||
CompletionCondition completion_condition_;
|
||||
ReadHandler handler_;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/completion_condition.hpp>
|
||||
#include <boost/asio/detail/bind_handler.hpp>
|
||||
@@ -129,25 +125,23 @@ namespace detail
|
||||
std::size_t bytes_transferred)
|
||||
{
|
||||
total_transferred_ += bytes_transferred;
|
||||
buffers_->consume(bytes_transferred);
|
||||
if ((*completion_condition_)(ec, total_transferred_)
|
||||
|| buffers_->begin() == buffers_->end())
|
||||
buffers_.consume(bytes_transferred);
|
||||
if (completion_condition_(ec, total_transferred_)
|
||||
|| buffers_.begin() == buffers_.end())
|
||||
{
|
||||
buffers_.reset();
|
||||
completion_condition_.reset();
|
||||
handler_(ec, total_transferred_);
|
||||
}
|
||||
else
|
||||
{
|
||||
stream_.async_write_some(*buffers_, *this);
|
||||
stream_.async_write_some(buffers_, *this);
|
||||
}
|
||||
}
|
||||
|
||||
//private:
|
||||
AsyncWriteStream& stream_;
|
||||
boost::optional<buffers_type> buffers_;
|
||||
buffers_type buffers_;
|
||||
std::size_t total_transferred_;
|
||||
boost::optional<CompletionCondition> completion_condition_;
|
||||
CompletionCondition completion_condition_;
|
||||
WriteHandler handler_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user