Skip to content

Commit 405c5dc

Browse files
committed
fixing fcd replay leaks #13
1 parent 1a670db commit 405c5dc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/microsim/devices/MSDevice_FCDReplay.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ MSDevice_FCDReplay::FCDHandler::updateTrafficObjects(const SUMOTime intervalStar
349349
}
350350
MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(vType);
351351
if (vehicleType == nullptr) {
352+
delete params;
352353
throw ProcessError(TLF("Unknown vType '%'.", vType));
353354
}
354355
if (routeEdges.front() == nullptr) {
@@ -357,6 +358,7 @@ MSDevice_FCDReplay::FCDHandler::updateTrafficObjects(const SUMOTime intervalStar
357358
} else {
358359
WRITE_WARNINGF(TL("No lane in fcd replay file for vehicle '%' at time %."), id, time2string(t.front().time));
359360
}
361+
delete params;
360362
continue;
361363
}
362364
if (isPerson) {
@@ -365,11 +367,12 @@ MSDevice_FCDReplay::FCDHandler::updateTrafficObjects(const SUMOTime intervalStar
365367
MSTransportable* person = MSNet::getInstance()->getPersonControl().buildPerson(params, vehicleType, plan, nullptr);
366368
person->getSingularType().setVClass(SVC_IGNORING);
367369
if (!MSNet::getInstance()->getPersonControl().add(person)) {
370+
delete person;
368371
throw ProcessError(TLF("Duplicate person '%'.", id));
369372
}
370373
MSTransportableDevice_FCDReplay* device = static_cast<MSTransportableDevice_FCDReplay*>(person->getDevice(typeid(MSTransportableDevice_FCDReplay)));
371374
if (device == nullptr) { // Person did not get a replay device
372-
// TODO delete person
375+
delete person;
373376
continue;
374377
}
375378
device->setTrajectory(&t);
@@ -416,16 +419,19 @@ MSDevice_FCDReplay::FCDHandler::updateTrafficObjects(const SUMOTime intervalStar
416419
const int stageIndex = person->getNumRemainingStages() - 1;
417420
MSStage* const final = person->getNextStage(stageIndex);
418421
bool append = false;
419-
for (MSStage* stage : *plan) {
422+
for (MSStage* const stage : *plan) {
420423
if (stage->getStageType() == final->getStageType() && stage->getFromEdge() == final->getFromEdge()) {
421424
// TODO: circular plans?
422425
append = true;
423426
}
424427
if (append) {
425428
person->appendStage(stage);
429+
} else {
430+
delete stage;
426431
}
427432
}
428433
person->removeStage(stageIndex);
434+
delete plan;
429435
} else {
430436
SUMOVehicle* vehicle = MSNet::getInstance()->getVehicleControl().getVehicle(id);
431437
ConstMSEdgeVector checkedRoute = checkRoute(routeEdges, vehicle);

0 commit comments

Comments
 (0)