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:
Gene Payne
2019-08-12 13:25:56 -06:00
committed by GitHub
parent 798ba573cf
commit dc45be045b
2 changed files with 11 additions and 3 deletions
+5 -1
View File
@@ -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;