[mlpack-git] master: Fix particularly subtle bug that tried to free statically-allocated memory. (17874a8)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Mon Jul 13 04:05:05 EDT 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/8b2ca720828224607c70d2b539c43aecf8f4ec32...b4659b668021db631b3c8a48e3d735b513706fdc

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

commit 17874a8c0a6353df6e7b8ea1eb86c2e562a32c6c
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Jul 13 06:51:45 2015 +0000

    Fix particularly subtle bug that tried to free statically-allocated memory.


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

17874a8c0a6353df6e7b8ea1eb86c2e562a32c6c
 src/mlpack/core/arma_extend/Mat_extra_meat.hpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mlpack/core/arma_extend/Mat_extra_meat.hpp b/src/mlpack/core/arma_extend/Mat_extra_meat.hpp
index 251ccc6..17fabdc 100644
--- a/src/mlpack/core/arma_extend/Mat_extra_meat.hpp
+++ b/src/mlpack/core/arma_extend/Mat_extra_meat.hpp
@@ -18,8 +18,11 @@ void Mat<eT>::serialize(Archive& ar, const unsigned int /* version */)
   // mem_state will always be 0 on load, so we don't need to save it.
   if (Archive::is_loading::value)
   {
-    if (mem_state == 0 && mem != NULL && old_n_elem > 0)
+    // Don't free if local memory is being used.
+    if (mem_state == 0 && mem != NULL && old_n_elem > arma_config::mat_prealloc)
+    {
       memory::release(access::rw(mem));
+    }
 
     access::rw(mem_state) = 0;
 



More information about the mlpack-git mailing list