]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliLego.cxx
Fix for Coverity 10007: BAD_FREE
[u/mrichter/AliRoot.git] / STEER / AliLego.cxx
index a118d5250f41ce018891143c1acd575fe850a485..5e5e53563ec6418279bf06ddaf13217498cf8920 100644 (file)
@@ -314,7 +314,7 @@ void AliLego::StepManager()
            TClonesArray &lvols = *fVolumesFwd;
            if (fStepsForward > 0) {
                AliDebugVolume* tmp = dynamic_cast<AliDebugVolume*>((*fVolumesFwd)[fStepsForward-1]);
-               if (tmp->IsVEqual(vol, copy) && gMC->IsTrackEntering()) {
+               if (tmp && tmp->IsVEqual(vol, copy) && gMC->IsTrackEntering()) {
                    fStepsForward -= 2;
                    fVolumesFwd->RemoveAt(fStepsForward);
                    fVolumesFwd->RemoveAt(fStepsForward+1);               
@@ -419,7 +419,7 @@ void AliLego::StepManager()
            new(lvols[fStepsBackward]) AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status);
            
            AliDebugVolume* tmp = dynamic_cast<AliDebugVolume*>((*fVolumesFwd)[fStepsBackward]);
-           if ((tmp->IsVEqual(vol, copy)) && (!fErrorCondition)) 
+           if (tmp && !(tmp->IsVEqual(vol, copy)) && (!fErrorCondition)) 
            {
                AliWarning(Form("Problem at (x,y,z): %d %f %f %f, volumes: %s %s step: %f\n", 
                                fStepsBackward, pos[0], pos[1], pos[2], tmp->GetName(), vol, step));