[ODE] Memleaks in collision_trimesh_trimesh.cpp

Jeffrey Smith jeffreys at Softimage.com
Thu May 20 10:37:23 MST 2004


Anton Savin wrote:
> I've found two memleaks in collision_trimesh_trimesh.cpp.
> there are at lines
>
> 492: firstClippedElt = new dVector3[firstClippedTri.Count];
>
> 593: secondClippedElt = new dVector3[secondClippedTri.Count];
>
> These pointers are allocated in the cycle
>      for (int i = 0; i < TriCount; i++)
>
> but deleted only after it.

Oops; my bad. I misplaced an end-bracket. To fix it, move the line

     } // if (OutTriCount < (Flags & 0xffff))

from before the delete's to after them.  Better yet, substitute the
code:
                  // Free memory
			delete[] firstClippedElt;
			firstClippedElt = NULL;
			delete[] secondClippedElt;
			firstClippedElt = NULL;
			
                  } // if (OutTriCount < (Flags & 0xffff))

in the appropriate place, to eliminate the useless non-nullness
checks.

-jeff



More information about the ODE mailing list