<p>I tried to compare the vantage point tree with <code>BallTree</code> and came across a segfault.</p>

<p>Since <code>BallBound[d].Mid()</code> is equal to the center, one child may be empty. In this case the following loop may lead to a segfault (if <code>right = 0</code> then <code>right-1 = SIZE_MAX</code>)</p>

<pre><code> while ((data(splitDimension, right) &gt;= splitVal) &amp;&amp; (left &lt;= right))
   right--;
</code></pre>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>&nbsp;&nbsp;<a href='https://github.com/mlpack/mlpack/pull/741'>https://github.com/mlpack/mlpack/pull/741</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Fixed an error in MidpointSplit that may lead to a segfault</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/741/files#diff-0">src/mlpack/core/tree/binary_space_tree/midpoint_split_impl.hpp</a>
    (28)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/mlpack/mlpack/pull/741.patch'>https://github.com/mlpack/mlpack/pull/741.patch</a></li>
  <li><a href='https://github.com/mlpack/mlpack/pull/741.diff'>https://github.com/mlpack/mlpack/pull/741.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/pull/741">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFGMGD10i8erSZ5GS8GYizp4onAXkks5qZ3SUgaJpZM4JWS3I">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFHR8hIzne3Sll5H_9LMuqplV1bgmks5qZ3SUgaJpZM4JWS3I.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/741"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>