[Bug 973] New: Problems allocating/deallocating memory in the Trajectory* classes


Summary: Problems allocating/deallocating memory in the
Trajectory* classes
Product: KDL
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P3
Component: Path planning and interpolation
AssignedTo: orocos-dev [..] ...
ReportedBy: Erwin [dot] Aertbelien [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

The following bug was repprted by alexey [dot] zakharov [..] ...:

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;

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) {
duration += elem->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,

[Bug 973] Problems allocating/deallocating memory in the Traject


Erwin Aertbelien <Erwin [dot] Aertbelien [..] ...> changed:

What |Removed |Added
Resolution| |FIXED