Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix use-after-scope.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 17 Dec 2020 08:43:19 +0000 (09:43 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 17 Dec 2020 11:02:23 +0000 (12:02 +0100)
examples/s4u/replay-comm/s4u-replay-comm.cpp
teshsuite/s4u/actor-suspend/actor-suspend.cpp

index 39e8ac6..e04bd78 100644 (file)
@@ -60,8 +60,6 @@ public:
     ACT_DEBUG("Entering Send: %s (size: %" PRIu64 ") -- Actor %s on mailbox %s", NAME.c_str(), size,
               simgrid::s4u::this_actor::get_cname(), to->get_cname());
     to->put(payload, size);
-    delete payload;
-
     log_action(action, simgrid::s4u::Engine::get_clock() - clock);
   }
 
@@ -73,7 +71,7 @@ public:
 
     ACT_DEBUG("Receiving: %s -- Actor %s on mailbox %s", NAME.c_str(), simgrid::s4u::this_actor::get_cname(),
               from->get_cname());
-    from->get();
+    delete static_cast<std::string*>(from->get());
     log_action(action, simgrid::s4u::Engine::get_clock() - clock);
   }
 };
index 585f564..3e82259 100644 (file)
@@ -41,7 +41,7 @@ public:
 
     XBT_INFO("Sending a message to the receiver...");
     auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
-    int data     = 42;
+    static int data = 42;
     mailbox->put(&data, 4);
 
     XBT_INFO("Done!");