Commit: 1e3904677c8c66d8e2d29189273a81a6b5a47e38
Author: Campbell Barton
Date:   Sat Apr 26 06:55:36 2014 +1000
https://developer.blender.org/rB1e3904677c8c66d8e2d29189273a81a6b5a47e38

Avoid integer overflow in build_implicit_tree_helper

===================================================================

M       source/blender/blenlib/intern/BLI_kdopbvh.c

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c 
b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 6fdfac2..6b1fbe8 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;
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to