RSS
 

Posts Tagged ‘memory leak’

double-check your damn pointers, okay?

13 feb

Yesterday, working on my thesis, I felt like I died and resurrected more than once in a few hours. Trust me, I’m beginning to understand the way the compiler feels ;-)

Jokes apart, the following C++ code contains a bug similar to the one I found: can you spot it? (please forgive the bad indent )

void calledMethod( some_class *object )
{
arg = doSomething();
delete object;
object = new some_class( arg );
}

void callerMethod()
{
[...]
calledMethod( anObject );
anObject.doSomethingElse();
[...]
}

 
4 Comments

Posted in geek, me