]> git.sesse.net Git - tcxmerge/commitdiff
Fix a possible infinite recursion in the BSP splitter.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 1 Sep 2012 23:07:14 +0000 (01:07 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 1 Sep 2012 23:07:14 +0000 (01:07 +0200)
opt.cc

diff --git a/opt.cc b/opt.cc
index bd70b4173443c9765d689e534e5fc24d5dd46f6f..bb318a4729e142cef336280798aa9e0fdfda4ac1 100644 (file)
--- a/opt.cc
+++ b/opt.cc
@@ -128,6 +128,13 @@ BSPTreeNode* make_bsp_tree(const vector<int>& remaining_roads)
                }
        }
 
+       if (left.empty() || right.empty()) {
+               node->is_leaf = true;
+               node->left = node->right = NULL;
+               node->roads_this_node = remaining_roads;
+               return node;
+       }
+
        if (left.size() == 0) {
                node->left = NULL;
        } else {