Page 1 of 1

Hidden bug?

Posted: 19.10.2005, 10:31
by Joe
A corrupted add-on file in my XP machine incidently (for somehow) assigned a null Orbit pointer to the function which triggered a debugging process that brought me to the code in the source file body.cpp

Code: Select all

 void Body::setOrbit(Orbit* _orbit)
{
  if (orbit == NULL)
      delete orbit;
 orbit = _orbit;
}


Is it correct about if (orbit == NULL) delete orbit; or should it be:

Code: Select all

if (orbit != NULL)
     delete orbit;

Posted: 25.10.2005, 10:28
by Joe
it seems my question is of no interests to anyone :oops: , but I wish to get some advice from your programming experts if this is a bug or not?

Posted: 25.10.2005, 12:57
by steffens
This definitely looks like a bug (memory leak). This code is present in the latest FT 1.1 version. Don't know if this is triggered though...

steffens

Posted: 26.10.2005, 08:34
by Joe
Yep, I tried the code

Code: Select all


void Body::setOrbit(Orbit* _orbit)
{
  if (orbit != NULL)
      delete orbit;
 orbit = _orbit;
}


in place of

Code: Select all

void Body::setOrbit(Orbit* _orbit)
{
  if (orbit == NULL)
      delete orbit;
 orbit = _orbit;
}


the problem solved :D . It is a bug.

Posted: 06.12.2005, 09:01
by steffens
As a new pre-release seems to be in preparation - this bug is still in CVS. It's easy to fix, so maybe it should be :wink:

steffens

Posted: 14.12.2005, 16:10
by steffens
Now this bug is in the latest pre-release, congratulations!
Is it going to be in 1.4 final? Or is it not a bug after all?

I can't believe that nobody cares to fix such a simple thing :cry:

steffens

Posted: 14.12.2005, 16:22
by dirkpitt
I've posted a heads-up in the developers' mailing list. Hopefully this will be fixed soon.

Posted: 14.12.2005, 18:09
by chris
The memory leak is fixed now. Thanks for pointing it out, and thanks to dirkpitt for mentioning it on the developers list.

--Chris