From e60db5c6957a9b93a5b83f3212663c451c5d06d3 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 30 Apr 2018 18:46:43 +0200 Subject: [PATCH] Avoid accessing elements of a zero size vector in ParticleHandler --- source/particles/particle_handler.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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.")); } -- 2.39.5