From: wolf Date: Mon, 30 Sep 2002 21:19:54 +0000 (+0000) Subject: Fix a memory allocation bug in one of the MA27 functions (and probably in MA47 as... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2eb7e32e830a77a3267bc6414e73195631c8fa88;p=dealii-svn.git Fix a memory allocation bug in one of the MA27 functions (and probably in MA47 as well). We were just writing over the end of an array. git-svn-id: https://svn.dealii.org/trunk@6568 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index 6492f64958..1b19bfc199 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -275,6 +275,15 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

lac

    +
  1. + Fixed: In the SparseDirectMA27 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. +
    + (WB 2002/09/30) +

    +
  2. New: Since the MA27 sparse direct solver uses Fortran common blocks, it was previously impossible to run several instances of this solver in diff --git a/deal.II/lac/source/sparse_direct.cc b/deal.II/lac/source/sparse_direct.cc index b90dc4bbd1..e5ac9692d7 100644 --- a/deal.II/lac/source/sparse_direct.cc +++ b/deal.II/lac/source/sparse_direct.cc @@ -537,7 +537,8 @@ SparseDirectMA27::factorize (const SparseMatrix &matrix) // set LA and fill the A array of // values - LA = static_cast(NRLNEC * LA_factor); + LA = std::max (static_cast(NRLNEC * LA_factor), + static_cast(n_nonzero_elements)); A.resize (LA); fill_A (matrix); @@ -719,7 +720,8 @@ SparseDirectMA27::get_synchronisation_lock () const void SparseDirectMA27::fill_A (const SparseMatrix &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 &m) // set LA and fill the A array of // values - LA = static_cast(INFO[5] * LA_factor); + LA = std::max (static_cast(INFO[5] * LA_factor), + static_cast(n_nonzero_elements)); A.resize (LA); fill_A (m);