correct dereference of iterator incremented past end()

This commit is contained in:
Robert Ramey
2016-03-08 12:34:51 -08:00
parent c0f17d6934
commit 5988a816f9
4 changed files with 12 additions and 7 deletions

View File

@@ -9,7 +9,8 @@
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX11_HDR_CODECVT
//#ifdef BOOST_NO_CXX11_HDR_CODECVT
#if 1
#include <boost/archive/detail/decl.hpp>
#define BOOST_UTF8_BEGIN_NAMESPACE \
namespace boost { namespace archive { namespace detail {

View File

@@ -143,15 +143,16 @@ template<class Base>
void wchar_from_mb<Base>::drain(){
BOOST_ASSERT(! m_input.m_done);
for(;;){
typename boost::iterators::iterator_reference<Base>::type c = *(this->base_reference()++);
* const_cast<typename iterator_value<Base>::type *>(
(m_input.m_next_available++)
) = c;
typename boost::iterators::iterator_reference<Base>::type c = *(this->base_reference());
// a null character in a multibyte stream is takes as end of string
if(0 == c){
m_input.m_done = true;
break;
}
++(this->base_reference());
* const_cast<typename iterator_value<Base>::type *>(
(m_input.m_next_available++)
) = c;
// if input buffer is full - we're done for now
if(m_input.m_buffer.end() == m_input.m_next_available)
break;