From 98d993fa55c32f4bbbd7ab83f6233e0bb9251fb8 Mon Sep 17 00:00:00 2001 From: lzwdgc Date: Fri, 28 Jul 2017 03:06:25 +0300 Subject: [PATCH] Fix incorrect end_ index in buffer. --- src/common/buffer.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/common/buffer.cpp b/src/common/buffer.cpp index c2a6e19..6499dcd 100644 --- a/src/common/buffer.cpp +++ b/src/common/buffer.cpp @@ -134,16 +134,14 @@ uint32_t buffer::_write(const void *src, uint32_t size) if (!buf_) { buf_ = std::make_shared>(size); - size_ = buf_->size(); - end_ = index_ + size_; + end_ = size_ = buf_->size(); } if (index_ > end_) throw std::logic_error("buffer: out of range"); if (index_ + size > end_) { buf_->resize(index_ + size); - size_ = buf_->size(); - end_ = index_ + size_; + end_ = size_ = buf_->size(); } memcpy((uint8_t *)buf_->data() + index_, src, size); skip(size);