From: Daniel Arndt Date: Mon, 30 Apr 2018 16:46:43 +0000 (+0200) Subject: Avoid accessing elements of a zero size vector in ParticleHandler X-Git-Tag: v9.0.0-rc1~48^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e60db5c6957a9b93a5b83f3212663c451c5d06d3;p=dealii.git Avoid accessing elements of a zero size vector in ParticleHandler --- diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index 50760bf848..c2a4305a94 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -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 (&recv_data.front()); + const void *recv_data_it = static_cast (recv_data.data()); - while (reinterpret_cast (recv_data_it) - reinterpret_cast (&recv_data.front()) < total_recv_data) + while (reinterpret_cast (recv_data_it) - reinterpret_cast (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.")); }