KDL::Trajectory_Composite memory deallocation problem

Dear KDL developers, I recently noticed a memory deallocation
problem in Trajectory_Composite class destructor.

The problem is in the Trajectory_Composite::Destroy() method.

void Trajectory_Composite::Destroy() {
VectorTraj::iterator it;
for (it=vt.begin();it!=vt.end();it++) {
delete *it;
}
vt.erase(vt.begin(),vt.end());
vd.erase(vd.begin(),vd.end());

delete path;
}

Here you twice release the same memory, the result is a segmentation fault.
As you can see, the method releases a vector of trajectories and than
destroys a path (Path_Composite). The problem is, that Path_Composite
and the trajectory vector elements point to the same objects, which
are path segment.

Solution of the problem is very easy, in Trajectory_Composite::Add
method, specify that Path_Composite should not aggregate path segment.

Here it is

void Trajectory_Composite::Add(Trajectory* elem) {
vt.insert(vt.end(),elem);
duration += elem->Duration();
vd.insert(vd.end(),duration);
path->Add(elem->GetPath(), false);
}

A false flag in path->Add(elem->GetPath(), false) should be added;
After that tiny modification,
the problem has gone and there are no memory leaks, I checked!

best regards,
Alexey

KDL::Trajectory_Composite memory deallocation problem

Dear KDL developers, I recently noticed a memory deallocation
problem in Trajectory_Composite class destructor.

The problem is in the Trajectory_Composite::Destroy() method.

void Trajectory_Composite::Destroy() {
VectorTraj::iterator it;
for (it=vt.begin();it!=vt.end();it++) {
delete *it;
}
vt.erase(vt.begin(),vt.end());
vd.erase(vd.begin(),vd.end());

delete path;
}

Here you twice release the same memory, the result is a segmentation fault.
As you can see, the method releases a vector of trajectories and than
destroys a path (Path_Composite). The problem is, that Path_Composite
and the trajectory vector elements point to the same objects, which
are path segment.

Solution of the problem is very easy, in Trajectory_Composite::Add
method, specify that Path_Composite should not aggregate path segment.

Here it is

void Trajectory_Composite::Add(Trajectory* elem) {
vt.insert(vt.end(),elem);
duration += elem->Duration();
vd.insert(vd.end(),duration);
path->Add(elem->GetPath(), false);
}

A false flag in path->Add(elem->GetPath(), false) should be added;
After that tiny modification,
the problem has gone and there are no memory leaks, I checked!

best regards,
Alexey