mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-24 13:28:55 -05:00
Added a check to prevent buffer sync buffer overflow, and expand buff… (#937)
* Added a check to prevent buffer sync buffer overflow, and expand buffer size if needed. * Removed unnecessary asserts and added sync buffer overflow check to encode template
This commit is contained in:
@@ -30,7 +30,11 @@ namespace openspace {
|
||||
template <typename T>
|
||||
void SyncBuffer::encode(const T& v) {
|
||||
const size_t size = sizeof(T);
|
||||
ghoul_assert(_encodeOffset + size < _n, "");
|
||||
|
||||
size_t anticpatedBufferSize = _encodeOffset + size;
|
||||
if (anticpatedBufferSize >= _n) {
|
||||
_dataStream.resize(anticpatedBufferSize);
|
||||
}
|
||||
|
||||
memcpy(_dataStream.data() + _encodeOffset, &v, size);
|
||||
_encodeOffset += size;
|
||||
|
||||
Reference in New Issue
Block a user