diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-01-14 15:11:55 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-01-14 15:16:06 +0400 |
commit | e7d18eb7bd706624183dd6d65f3e55faa5fb1956 (patch) | |
tree | 99f58cbf148bf47f52d411294d332c9aba7374a0 /source | |
parent | b7f04acb0c0fb8f3e8f0d5ca615d9bb8d52467bb (diff) |
Add check for KD tree size to BLI_kdtree_insert()
Makes sure we're not trying to insert more nodes than we've
been expecting to.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdtree.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index c0e7c21420a..844d8502ff0 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -46,6 +46,7 @@ struct KDTree { KDTreeNode *root; #ifdef DEBUG bool is_balanced; /* ensure we call balance first */ + unsigned int maxsize; /* max size of the tree */ #endif }; @@ -67,6 +68,7 @@ KDTree *BLI_kdtree_new(unsigned int maxsize) #ifdef DEBUG tree->is_balanced = false; + tree->maxsize = maxsize; #endif return tree; @@ -87,6 +89,10 @@ void BLI_kdtree_insert(KDTree *tree, int index, const float co[3], const float n { KDTreeNode *node = &tree->nodes[tree->totnode++]; +#ifdef DEBUG + BLI_assert(tree->totnode < tree->maxsize); +#endif + /* note, array isn't calloc'd, * need to initialize all struct members */ |