]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid accessing elements of a zero size vector in ParticleHandler
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 30 Apr 2018 16:46:43 +0000 (18:46 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Tue, 1 May 2018 10:54:53 +0000 (12:54 +0200)
source/particles/particle_handler.cc

index 50760bf84815194e511759884afdbbdb5e05ad69..c2a4305a940a3c0dda5d0aa84c751d765d788852 100644 (file)
@@ -817,9 +817,9 @@ namespace Particles
     }
 
     // Put the received particles into the domain if they are in the triangulation
-    const void *recv_data_it = static_cast<const void *> (&recv_data.front());
+    const void *recv_data_it = static_cast<const void *> (recv_data.data());
 
-    while (reinterpret_cast<std::size_t> (recv_data_it) - reinterpret_cast<std::size_t> (&recv_data.front()) < total_recv_data)
+    while (reinterpret_cast<std::size_t> (recv_data_it) - reinterpret_cast<std::size_t> (recv_data.data()) < total_recv_data)
       {
         CellId::binary_type binary_cellid;
         memcpy(&binary_cellid, recv_data_it, cellid_size);
@@ -837,7 +837,7 @@ namespace Particles
                                        recv_data_it);
       }
 
-    AssertThrow(recv_data_it == &recv_data.back()+1,
+    AssertThrow(total_recv_data == 0 || recv_data_it == &recv_data.back()+1,
                 ExcMessage("The amount of data that was read into new particles "
                            "does not match the amount of data sent around."));
   }

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.