From 15cd5d90f4861da24c971f5ea186d542c4d32067 Mon Sep 17 00:00:00 2001 From: David Williams Date: Mon, 9 Apr 2012 11:00:35 +0200 Subject: [PATCH] More validation of block sizes. --- .../PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl index 14bed170..536fe065 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl @@ -177,12 +177,18 @@ namespace PolyVox void SimpleVolume::resize(const Region& regValidRegion, uint16_t uBlockSideLength) { //Debug mode validation - assert(uBlockSideLength > 0); + assert(uBlockSideLength >= 8); + assert(uBlockSideLength <= 256); + assert(isPowerOf2(uBlockSideLength)); //Release mode validation - if(uBlockSideLength == 0) + if(uBlockSideLength < 8) { - throw std::invalid_argument("Block side length cannot be zero."); + throw std::invalid_argument("Block side length should be at least 8"); + } + if(uBlockSideLength > 256) + { + throw std::invalid_argument("Block side length should not be more than 256"); } if(!isPowerOf2(uBlockSideLength)) {