<p>In <a href="https://github.com/mlpack/mlpack/pull/664#discussion_r67772247">src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value_impl.hpp</a>:</p>
<pre style='color:#555'>&gt; +    ownsLocalDataset = true;
&gt; +  }
&gt; +    
&gt; +  if (ownsLocalDataset)
&gt; +  {
&gt; +    localDataset =  new arma::Mat&lt;HilbertElemType&gt;(tree-&gt;Dataset().n_rows,
&gt; +                                            tree-&gt;MaxLeafSize() + 1);
&gt; +  }
&gt; +
&gt; +}
&gt; +
&gt; +template&lt;typename TreeElemType&gt;
&gt; +DiscreteHilbertValue&lt;TreeElemType&gt;::
&gt; +DiscreteHilbertValue(const DiscreteHilbertValue&amp; other) :
&gt; +    localDataset(const_cast&lt;arma::Mat&lt;HilbertElemType&gt;*&gt;(other.LocalDataset())),
&gt; +    ownsLocalDataset(other.ownsLocalDataset),
</pre>
<p>I think that I could cause an invalid delete if I did this:</p>

<pre><code>{
  DiscreteHilbertValue a(someNode); // someNode should be the root
  DiscreteHilbertValue b(a); // Calls this copy constructor.
} // When b's destructor is called, a.localDataset is freed a second time
</code></pre>

<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/664/files/f9127cea62d5ce1ad8d5f59931de108a2f7cdd9b#r67772247">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFP-RWYN095U0SVrCQYu3BI1UaKKMks5qNwlRgaJpZM4IrlzT">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFEGXcR_cIJwDrBHG5fiO-tz1oUgCks5qNwlRgaJpZM4IrlzT.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/664/files/f9127cea62d5ce1ad8d5f59931de108a2f7cdd9b#r67772247"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>