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