Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix use-after-free.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 26 Nov 2020 11:47:27 +0000 (12:47 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 26 Nov 2020 12:28:58 +0000 (13:28 +0100)
src/smpi/mpi/smpi_datatype.cpp

index 0dcfaef..6e9fe3d 100644 (file)
@@ -211,13 +211,13 @@ void Datatype::unref(MPI_Datatype datatype)
   if (datatype->refcount_ > 0)
     datatype->refcount_--;
 
-  if (datatype->refcount_ == 0 && not(datatype->flags_ & DT_FLAG_PREDEFINED))
-    delete datatype;
-
 #if SIMGRID_HAVE_MC
   if(MC_is_active())
     MC_ignore(&(datatype->refcount_), sizeof(datatype->refcount_));
 #endif
+
+  if (datatype->refcount_ == 0 && not(datatype->flags_ & DT_FLAG_PREDEFINED))
+    delete datatype;
 }
 
 void Datatype::commit()