From 4f1b0e473b874b28fe19fcbb6b1e7b3cde27b11e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 10 Aug 2012 12:38:53 +0000 Subject: add asserts in MemoryBuffer.readNoCheck() so it raises an error when used incorrectly in debug mode. --- source/blender/compositor/intern/COM_MemoryBuffer.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/compositor') diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h index f64603ed5d9..142f05af250 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.h +++ b/source/blender/compositor/intern/COM_MemoryBuffer.h @@ -29,6 +29,8 @@ class MemoryBuffer; #include "BLI_rect.h" #include "COM_MemoryProxy.h" +#include "MEM_guardedalloc.h" + extern "C" { //#include "BLI_threads.h" #include "BLI_math.h" @@ -147,6 +149,18 @@ public: const int dx = x - this->m_rect.xmin; const int dy = y - this->m_rect.ymin; const int offset = (this->m_chunkWidth * dy + dx) * COM_NUMBER_OF_CHANNELS; + + BLI_assert(offset >= 0); + BLI_assert(offset < this->determineBufferSize() * COM_NUMBER_OF_CHANNELS); + BLI_assert(x >= this->m_rect.xmin && x < this->m_rect.xmax && + y >= this->m_rect.ymin && y < this->m_rect.ymax); + +#if 0 + /* always true */ + BLI_assert((int)(MEM_allocN_len(this->m_buffer) / sizeof(*this->m_buffer)) == + (int)(this->determineBufferSize() * COM_NUMBER_OF_CHANNELS)); +#endif + copy_v4_v4(result, &this->m_buffer[offset]); } -- cgit v1.2.3