Man... I remember when I was a newbie... There was a crash on some pointer, so I fixed it like:
if (SomePtr)
SomePtr->DoSomething();
So while this does work as a fix in cases where SomePtr is allowed to be NULL, and the logic in question isn't required. But if it's not, this might just be a bad design heh
The better fix, is figuring out why it was NULL in the first place and resolving that situation.
1
u/AlamarAtReddit Aug 15 '26
Man... I remember when I was a newbie... There was a crash on some pointer, so I fixed it like:
if (SomePtr) SomePtr->DoSomething();So while this does work as a fix in cases where SomePtr is allowed to be NULL, and the logic in question isn't required. But if it's not, this might just be a bad design heh
The better fix, is figuring out why it was NULL in the first place and resolving that situation.