microsoft / MixedReality-UXTools-Unreal

UX tools and components for developing Mixed Reality applications in UE4.
https://microsoft.github.io/MixedReality-UXTools-Unreal/
MIT License
316 stars 86 forks source link

FindFarTarget() has to check owner before For-Loop. #27

Closed crssnky closed 3 years ago

crssnky commented 3 years ago

UxtFarPointerComponent.cpp

// Finds the far target a primitive belongs to, if any
static UObject* FindFarTarget(UPrimitiveComponent* Primitive)
{
    if (Primitive)
    {
        for (UActorComponent* Component : Primitive->GetOwner()->GetComponents())  // <-- No check "owner==nullptr"
        {
            if (Component->Implements<UUxtFarTarget>() && IUxtFarTarget::Execute_IsFarFocusable(Component, Primitive))
            {
                return Component;
            }
        }
    }

    return nullptr;
}

I use GeometryBrush actors in PIE. UE4 crashes in FindFarTarget() when FarPointer touches a GeometryBrush actor. GeometryBrush actors does not have owner. It has to check owner before For-Loop.

Maybe, there are others like this.

lukastoenneMS commented 3 years ago

Thanks for reporting! This is fixed in the master branch now (link to commit) We've had a couple of places where it was assumed GetOwner() would always be valid. There should be proper checks everywhere now, even though in practice it should only come up when looking at other components such as the geometry brush.