Skip to content

Commit

Permalink
fixing memleak and access to deleted object #13
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Jan 23, 2024
1 parent 420daad commit 69d663f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/microsim/transportables/MSPModel_JuPedSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ MSPModel_JuPedSim::add(MSTransportable* person, MSStageMoving* stage, SUMOTime n
JPS_StageId predecessor = 0;
for (const Position& p : waypoints) {
if (!addWaypoint(journey, predecessor, p, person->getID())) {
JPS_JourneyDescription_Free(journey);
return nullptr;
}
if (startingStage == 0) {
Expand Down Expand Up @@ -326,10 +327,11 @@ MSPModel_JuPedSim::execute(SUMOTime time) {
if (state->advanceNextWaypoint()) {
// TODO this only works if the final stage is actually a walk
const bool finalStage = person->getNumRemainingStages() == 1;
const JPS_AgentId agentID = state->getAgentId();
while (!stage->moveToNextEdge(person, time, 1, nullptr));
if (finalStage) {
registerArrived();
JPS_Simulation_MarkAgentForRemoval(myJPSSimulation, state->getAgentId(), nullptr);
JPS_Simulation_MarkAgentForRemoval(myJPSSimulation, agentID, nullptr);
stateIt = myPedestrianStates.erase(stateIt);
continue;
}
Expand Down

0 comments on commit 69d663f

Please sign in to comment.