Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix UBSan warning.
[simgrid.git] / src / smpi / mpi / smpi_datatype.cpp
index 158bb2e..a7ea791 100644 (file)
@@ -356,7 +356,7 @@ int Datatype::copy(const void* sendbuf, int sendcount, MPI_Datatype sendtype, vo
     int count = sendcount < recvcount ? sendcount : recvcount;
     XBT_DEBUG("Copying %d bytes from %p to %p", count, sendbuf, recvbuf);
     if (not(sendtype->flags() & DT_FLAG_DERIVED) && not(recvtype->flags() & DT_FLAG_DERIVED)) {
-      if (not smpi_process()->replaying())
+      if (not smpi_process()->replaying() && count > 0)
         memcpy(recvbuf, sendbuf, count);
     } else if (not(sendtype->flags() & DT_FLAG_DERIVED)) {
       recvtype->unserialize(sendbuf, recvbuf, count / recvtype->size(), MPI_REPLACE);