]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix a memory allocation bug in one of the MA27 functions (and probably in MA47 as...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 30 Sep 2002 21:19:54 +0000 (21:19 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 30 Sep 2002 21:19:54 +0000 (21:19 +0000)
git-svn-id: https://svn.dealii.org/trunk@6568 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/2002/c-3-4.html
deal.II/lac/source/sparse_direct.cc

index 6492f649585cf6033a723002b9e5f43bb55351ad..1b19bfc1998b083eb3ec3b6f3debcb5bc3e3b99c 100644 (file)
@@ -275,6 +275,15 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>lac</h3>
 
 <ol>
+  <li> <p>
+       Fixed: In the <code class="class">SparseDirectMA27</code> class, wrapping 
+       the MA27 solver written in Fortran77 into some structure amenable to C++,
+       we wrote beyond the end of an array on rare inputs. This is now fixed. The
+       same probably holds for the respective code for MA47.
+       <br>
+       (WB 2002/09/30)
+       </p>
+
   <li> <p>
        New: Since the MA27 sparse direct solver uses Fortran common blocks, it
        was previously impossible to run several instances of this solver in
index b90dc4bbd1c016c529aabf1debea55f56bb310b6..e5ac9692d72c820e31e3f543c289751a209db0a2 100644 (file)
@@ -537,7 +537,8 @@ SparseDirectMA27::factorize (const SparseMatrix<double> &matrix)
   
                                   // set LA and fill the A array of
                                   // values
-  LA = static_cast<int>(NRLNEC * LA_factor);
+  LA = std::max (static_cast<int>(NRLNEC * LA_factor),
+                static_cast<int>(n_nonzero_elements));
   A.resize (LA);
   fill_A (matrix);
 
@@ -719,7 +720,8 @@ SparseDirectMA27::get_synchronisation_lock () const
 void
 SparseDirectMA27::fill_A (const SparseMatrix<double> &matrix)
 {
-  
+  Assert (n_nonzero_elements <= A.size(), ExcInternalError());
+
   const SparsityPattern &sparsity_pattern = matrix.get_sparsity_pattern ();
   
   const unsigned int n_rows = sparsity_pattern.n_rows();
@@ -1059,7 +1061,8 @@ SparseDirectMA47::factorize (const SparseMatrix<double> &m)
   
                                   // set LA and fill the A array of
                                   // values
-  LA = static_cast<int>(INFO[5] * LA_factor);
+  LA = std::max (static_cast<int>(INFO[5] * LA_factor),
+                static_cast<int>(n_nonzero_elements));
   A.resize (LA);
   fill_A (m);
   

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.