Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix UBSan warning.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 25 Oct 2020 13:55:01 +0000 (14:55 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 25 Oct 2020 13:55:01 +0000 (14:55 +0100)
smpi_datatype.cpp:360:15: runtime error: null pointer passed as argument 2, which is declared to never be null

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);