表达式:_BLOCK_TYPE_ISVAILD(pHead-> nBlockUse)

时间:2011-06-05 14:05:48

标签: c++ scope boost-asio

void Connection::Receive(){
    socket_.async_read_some(boost::asio::buffer(read_buffer_),
          boost::bind(&Connection::handle_Receive, shared_from_this(),boost::asio::placeholders::error));
}

void Connection::handle_Receive(const boost::system::error_code& error)
{
  if(!error)
  {
      if(read_buffer_.size() <=0){
          read_buffer_.empty();
          this->Disconnect();
      }
        ByteBuffer b((std::shared_ptr<uint8_t>)read_buffer_.data(), read_buffer_.size());
        this->OnReceived(b);
        read_buffer_.empty();
  }
//when it loses the if(!error) scope the error pop-up
    }

错误:

Debug Assertion Faild!

Program: D:\C++\Server\Debug\Authsever.exe
File:f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp
Expression: _BLOCK_TYPE_ISVAILD(pHead->nBlockUse)

当它丢失if(!error)范围时弹出错误,这个错误意味着什么?!

1 个答案:

答案 0 :(得分:0)

您正在通过将uint8_t*拥有的boost::array<uint8_t,1000>转换为std::shared_ptr进行双重删除。

    ByteBuffer b((std::shared_ptr<uint8_t>)read_buffer_.data(), read_buffer_.size());
                                        ^^^^^

不要这样做,shared_ptr用于指定动态存储持续时间的指针。