From e9dc6787ce259ded12ada51536bff5954a67b34c Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 11 Dec 2016 10:21:25 -1000 Subject: [PATCH] Buffer overflow fixes --- specter/include/specter/UniformBufferPool.hpp | 3 ++- specter/include/specter/VertexBufferPool.hpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/specter/include/specter/UniformBufferPool.hpp b/specter/include/specter/UniformBufferPool.hpp index 689e27c42..b375f191c 100644 --- a/specter/include/specter/UniformBufferPool.hpp +++ b/specter/include/specter/UniformBufferPool.hpp @@ -66,7 +66,8 @@ class UniformBufferPool void updateBuffer() { - buffer->unmap(); + if (buffer) + buffer->unmap(); cpuBuffer = nullptr; dirty = false; } diff --git a/specter/include/specter/VertexBufferPool.hpp b/specter/include/specter/VertexBufferPool.hpp index b0a07c34e..4f079fbc7 100644 --- a/specter/include/specter/VertexBufferPool.hpp +++ b/specter/include/specter/VertexBufferPool.hpp @@ -66,7 +66,8 @@ class VertexBufferPool void updateBuffer() { - buffer->unmap(); + if (buffer) + buffer->unmap(); cpuBuffer = nullptr; dirty = false; } @@ -106,7 +107,7 @@ public: assert(count <= pool.m_countPerBucket && "unable to fit in bucket"); auto& freeSpaces = pool.m_freeElements; auto& buckets = pool.m_buckets; - int idx = freeSpaces.find_first_contiguous(count); + int idx = freeSpaces.find_first_contiguous(count, pool.m_countPerBucket); if (idx == -1) { buckets.emplace_back();