While https://github.com/jlblancoc/nanoflann/pull/220 decreases amount of middleSplit_ calls, it also prevents finding correct min_elem and max_elem when max_span == 0 and span == 0. What leads to wrong cutval calculation and out of range reads at divideTree.
The issue can be observed with the unit test executed under valgrind.
While https://github.com/jlblancoc/nanoflann/pull/220 decreases amount of
middleSplit_
calls, it also prevents finding correctmin_elem
andmax_elem
whenmax_span == 0
andspan == 0
. What leads to wrongcutval
calculation and out of range reads atdivideTree
.The issue can be observed with the unit test executed under valgrind.