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 bd70b41..bb318a4 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 {
        if (left.size() == 0) {
                node->left = NULL;
        } else {