From 0f57a0584d2146f001cec2e4df702458909f2d55 Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Wed, 18 Jul 2018 17:42:35 -0700 Subject: [PATCH] Avoid out of bounds memory access --- source/base/data_out_base.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index a6f1f86197..ebb4f197cb 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -401,6 +401,10 @@ namespace DataOutBase const std::vector> &patches, Table<2, Number> & data_vectors) { + // If there is nothing to write, just return + if (patches.size() == 0) + return; + // unlike in the main function, we don't have here the data_names field, // so we initialize it with the number of data sets in the first patch. // the equivalence of these two definitions is checked in the main @@ -7594,6 +7598,9 @@ DataOutBase::write_filtered_data( // no cells it actually owns, and in that case it is legit if there are no // patches Assert(patches.size() > 0, ExcNoPatches()); +#else + if (patches.size() == 0) + return; #endif compute_sizes(patches, n_node, n_cell); -- 2.39.5