]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid out of bounds memory access
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Thu, 19 Jul 2018 00:42:35 +0000 (17:42 -0700)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Thu, 19 Jul 2018 00:42:35 +0000 (17:42 -0700)
source/base/data_out_base.cc

index a6f1f8619711994260932dd23ce9246b8a5aaf7e..ebb4f197cb388d931151ec6f8f1377592ceb87dd 100644 (file)
@@ -401,6 +401,10 @@ namespace DataOutBase
       const std::vector<Patch<dim, spacedim>> &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<dim, spacedim>(patches, n_node, n_cell);

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.