[mlpack-git] master: Fix memory leak when overwriting bounds. (d86e4e5)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Fri Jul 10 19:00:20 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/4a97187bbba7ce8a6191b714949dd818ef0f37d2...e5905e62c15d1bcff21e6359b11efcd7ab6d7ca0

>---------------------------------------------------------------

commit d86e4e5a80c06d45549ae21213a57c78578dc887
Author: ryan <ryan at ratml.org>
Date:   Tue Apr 28 12:13:13 2015 -0400

    Fix memory leak when overwriting bounds.


>---------------------------------------------------------------

d86e4e5a80c06d45549ae21213a57c78578dc887
 src/mlpack/core/tree/hrectbound_impl.hpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/mlpack/core/tree/hrectbound_impl.hpp b/src/mlpack/core/tree/hrectbound_impl.hpp
index 1f25528..116323b 100644
--- a/src/mlpack/core/tree/hrectbound_impl.hpp
+++ b/src/mlpack/core/tree/hrectbound_impl.hpp
@@ -430,7 +430,11 @@ void HRectBound<Power, TakeRoot>::Serialize(Archive& ar,
 
   // Allocate memory for the bounds, if necessary.
   if (Archive::is_loading::value)
+  {
+    if (bounds)
+      delete[] bounds;
     bounds = new math::Range[dim];
+  }
 
   ar & data::CreateArrayNVP(bounds, dim, "bounds");
   ar & data::CreateNVP(minWidth, "minWidth");



More information about the mlpack-git mailing list