diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h index 5cb48f7e145..33b5258dd94 100644 --- a/source/blender/render/intern/raytrace/reorganize.h +++ b/source/blender/render/intern/raytrace/reorganize.h @@ -287,6 +287,9 @@ static float bvh_refit(Node *node) #define MAX_CUT_SIZE 4 /* svbvh assumes max 4 children! */ #define MAX_OPTIMIZE_CHILDS MAX_CUT_SIZE +#define CUT_SIZE_IS_VALID(cut_size) ((cut_size) < MAX_CUT_SIZE && (cut_size) >= 0) + + struct OVBVHNode { float bb[6]; @@ -300,6 +303,7 @@ struct OVBVHNode { float cut_cost[MAX_CUT_SIZE]; float get_cost(int cutsize) { + assert(CUT_SIZE_IS_VALID(cutsize - 1)); return cut_cost[cutsize - 1]; } @@ -310,6 +314,7 @@ struct OVBVHNode { int cut_size[MAX_CUT_SIZE]; int get_cut_size(int parent_cut_size) { + assert(CUT_SIZE_IS_VALID(parent_cut_size - 1)); return cut_size[parent_cut_size - 1]; }