From: Wolfgang Bangerth Date: Wed, 21 Mar 2018 20:09:12 +0000 (-0600) Subject: Ensure we get no segmentation faults for empty matrices. X-Git-Tag: v9.0.0-rc1~287^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=586c3b03f8664ad2ef69167e95cd0cba8c54640b;p=dealii.git Ensure we get no segmentation faults for empty matrices. --- diff --git a/source/lac/sparsity_pattern.cc b/source/lac/sparsity_pattern.cc index c71504eee0..5c0a2f04b9 100644 --- a/source/lac/sparsity_pattern.cc +++ b/source/lac/sparsity_pattern.cc @@ -572,8 +572,12 @@ void SparsityPattern::copy_from (const FullMatrix &matrix) // but there are cases where it matters -- so we may as well be // gentler and hand over a whole row of entries at a time std::vector column_indices; - column_indices.reserve (*std::max_element (entries_per_row.begin(), - entries_per_row.end())); + column_indices.reserve (entries_per_row.size() > 0 + ? + *std::max_element (entries_per_row.begin(), + entries_per_row.end()) + : + 0); for (size_type row=0; row