]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix a memory leak in de-serializing a SparsityPattern object. 3523/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 11 Nov 2016 00:39:40 +0000 (17:39 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 11 Nov 2016 00:39:40 +0000 (17:39 -0700)
doc/news/changes.h
include/deal.II/lac/sparsity_pattern.h

index cefa9106e01bb4ce50239596482e4362f9e26e19..b4e8ea63bc3dfbe8207e86036ff84c99ac34d3ae 100644 (file)
@@ -437,6 +437,13 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+ <li> Fixed: There was a memory leak if a previously used SparsityPattern
+ object was re-used by reading from a serialization archive via
+ SparsityPattern::load(). This is now fixed.
+ <br>
+ (Wolfgang Bangerth, 2016/11/10)
+ </li>
+
  <li> New: Add PArpackSolver::reinit(const VectorType &distributed_vector) to
  initialize internal data structures based on a vector. This makes PArpack
  usable with MatrixFree operators.
index ce07d9e127f708d6cbd469da55a2aeb510815414..2db0dd3009abfc24a8a098c43fdcd023a189c53b 100644 (file)
@@ -1430,8 +1430,13 @@ SparsityPattern::load (Archive &ar, const unsigned int)
 
   ar &max_dim &rows &cols &max_vec_len &max_row_length &compressed &store_diagonal_first_in_row;
 
-  rowstart = new std::size_t [max_dim + 1];
-  colnums = new size_type [max_vec_len];
+  if (rowstart != 0)
+    delete[] rowstart;
+  rowstart = new std::size_t[max_dim + 1];
+
+  if (colnums != 0)
+    delete[] colnums;
+  colnums = new size_type[max_vec_len];
 
   ar &boost::serialization::make_array(rowstart, max_dim + 1);
   ar &boost::serialization::make_array(colnums, max_vec_len);

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.