Fix bytebuffer
This commit is contained in:
parent
27ab6193e5
commit
077167e81b
@ -1,7 +1,6 @@
|
||||
#include "byte_buffer.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace utils
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace utils
|
||||
{
|
||||
@ -73,8 +74,13 @@ namespace utils
|
||||
std::vector<T> read_vector()
|
||||
{
|
||||
std::vector<T> result{};
|
||||
result.resize(read<uint32_t>());
|
||||
read(result.data(), result.size() * sizeof(T));
|
||||
const auto size = read<uint32_t>();
|
||||
if (offset_ + size > buffer_.size())
|
||||
{
|
||||
throw std::runtime_error("Out of bounds read from byte buffer");
|
||||
}
|
||||
|
||||
read(result.data(), size);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user