summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-02-15 15:44:49 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-02-15 15:44:58 +0100
commit447e7acfb0c220f66d5fe25f31b25c989d4ec1d7 (patch)
tree5797527410083fd71adf43583eb95a004f897105
parente9fad320817cd8ab84f7ef81940fda63f975551e (diff)
downloadastra-447e7acfb0c220f66d5fe25f31b25c989d4ec1d7.tar.gz
astra-447e7acfb0c220f66d5fe25f31b25c989d4ec1d7.tar.bz2
astra-447e7acfb0c220f66d5fe25f31b25c989d4ec1d7.tar.xz
astra-447e7acfb0c220f66d5fe25f31b25c989d4ec1d7.zip
Avoid (unlikely) integer overflow
-rw-r--r--src/CompositeGeometryManager.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/CompositeGeometryManager.cpp b/src/CompositeGeometryManager.cpp
index 1991731..cafc452 100644
--- a/src/CompositeGeometryManager.cpp
+++ b/src/CompositeGeometryManager.cpp
@@ -362,7 +362,11 @@ static size_t ceildiv(size_t a, size_t b) {
static size_t computeLinearSplit(size_t maxBlock, int div, size_t sliceCount)
{
size_t blockSize = maxBlock;
- size_t blockCount = ceildiv(sliceCount, blockSize);
+ size_t blockCount;
+ if (sliceCount <= blockSize)
+ blockCount = 1;
+ else
+ blockCount = ceildiv(sliceCount, blockSize);
// Increase number of blocks to be divisible by div
size_t divCount = div * ceildiv(blockCount, div);