mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43:25 +00:00
Fix incorrect end_ index in buffer.
This commit is contained in:
parent
a0aab7807d
commit
98d993fa55
1 changed files with 2 additions and 4 deletions
|
|
@ -134,16 +134,14 @@ uint32_t buffer::_write(const void *src, uint32_t size)
|
||||||
if (!buf_)
|
if (!buf_)
|
||||||
{
|
{
|
||||||
buf_ = std::make_shared<std::vector<uint8_t>>(size);
|
buf_ = std::make_shared<std::vector<uint8_t>>(size);
|
||||||
size_ = buf_->size();
|
end_ = size_ = buf_->size();
|
||||||
end_ = index_ + size_;
|
|
||||||
}
|
}
|
||||||
if (index_ > end_)
|
if (index_ > end_)
|
||||||
throw std::logic_error("buffer: out of range");
|
throw std::logic_error("buffer: out of range");
|
||||||
if (index_ + size > end_)
|
if (index_ + size > end_)
|
||||||
{
|
{
|
||||||
buf_->resize(index_ + size);
|
buf_->resize(index_ + size);
|
||||||
size_ = buf_->size();
|
end_ = size_ = buf_->size();
|
||||||
end_ = index_ + size_;
|
|
||||||
}
|
}
|
||||||
memcpy((uint8_t *)buf_->data() + index_, src, size);
|
memcpy((uint8_t *)buf_->data() + index_, src, size);
|
||||||
skip(size);
|
skip(size);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue