diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-26 00:55:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-26 00:55:36 +0400 |
commit | 1e3904677c8c66d8e2d29189273a81a6b5a47e38 (patch) | |
tree | 8aaea28342c92114e8060528335137d99401958e /source/blender/blenlib | |
parent | d0533b6c07f525b103bed1003c5a89b0c83fe241 (diff) |
Avoid integer overflow in build_implicit_tree_helper
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdopbvh.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 6fdfac2e1cb..6b1fbe855a1 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -617,9 +617,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data) data->branches_on_level[0] = 1; - /* We could stop the loop first (but I am lazy to find out when) */ - /* note: this often causes integer overflow, may be worth avoiding? - campbell */ - for (depth = 1; depth < 32; depth++) { + for (depth = 1; (depth < 32) && data->leafs_per_child[depth - 1]; depth++) { data->branches_on_level[depth] = data->branches_on_level[depth - 1] * data->tree_type; data->leafs_per_child[depth] = data->leafs_per_child[depth - 1] / data->tree_type; } |