Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
prevents from adding invalid pointer to the dict
[simgrid.git] / src / simix / smx_network.c
index d0e9d70..8c8b16d 100644 (file)
@@ -163,10 +163,13 @@ void SIMIX_communication_destroy(smx_comm_t comm)
   VERB2("Destroy communication %p; refcount initially %d",comm,comm->refcount);
 
   //save is latency limited flag to use afterwards
-  if (latency_limited_dict == NULL)
+  if (latency_limited_dict == NULL) {
          latency_limited_dict = xbt_dict_new();
-  DEBUG2("adding key %p with latency limited value %d to the dict", comm, SIMIX_action_is_latency_bounded(comm->act));
-  xbt_dicti_set(latency_limited_dict, comm, SIMIX_action_is_latency_bounded(comm->act));
+  }
+  if (comm->act){
+    DEBUG2("adding key %p with latency limited value %d to the dict", comm, SIMIX_action_is_latency_bounded(comm->act));
+    xbt_dicti_set(latency_limited_dict, (uintptr_t)comm, SIMIX_action_is_latency_bounded(comm->act));
+  }
 
   comm->refcount--;
   if(comm->refcount > 0)
@@ -368,9 +371,9 @@ XBT_INLINE int SIMIX_communication_is_latency_bounded(smx_comm_t comm)
   uintptr_t data = 0;
   xbt_dict_cursor_t cursor;
   xbt_dict_foreach(latency_limited_dict,cursor,key,data) {
-    DEBUG2("comparing key=%p with comm=%p", key, comm);
-       if(comm == key){
-               DEBUG2("key %p found, return value latency limited value %d", key, data);
+    DEBUG2("comparing key=%p with comm=%p", (void*)key, (void*)comm);
+       if((void*)comm == (void*)key){
+               DEBUG2("key %p found, return value latency limited value %d", (void*)key, (int)data);
                return (int)data;
        }
   }