If I have the following setup:
Point* MyPoint = Object->GetMyPoint();
if(MyPoint->GetValue() != 2)
do something;
else
do something else;
If MyPoint is NULL or invalid, the MyPoint->GetValue() will cause a segfault.
This should fix it:
Point* MyPoint = Object->GetMyPoint();
if(MyPoint)
{
if(MyPoint->GetValue() != 2)
do A;
else
do B;
}
else
do B;
But that is quite awkward, as it makes me repeat B and it adds an extra nested layer.
Is there a better way to do this?
Thanks,
Dave