From: Rene Gassmoeller Date: Thu, 19 Jul 2018 00:42:35 +0000 (-0700) Subject: Avoid out of bounds memory access X-Git-Tag: v9.1.0-rc1~907^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f57a0584d2146f001cec2e4df702458909f2d55;p=dealii.git Avoid out of bounds memory access --- 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);