Access violation when calling Actor->GetAttachedActors()

I trigger an access violation when I call the Actor->GetAttachedActors() function in a class derived from the ACharacter class as it tries to read the root component:

What’s the best way to approach this? I don’t know if changing the root component will alter some of the ACharacter functionality (with regards pathfinding or whatever) and I’d rather not make any changes to the engine or anything.

This is the code calling the function:

Thanks in advance.

Before you use functions like that, call
​​​ AActor::GetRootComponent()
to see if it isn’t nullptr.

Oh right, it looks like GetOwner() is returning a nullptr. I logged the root component earlier but didn’t think to check if GetOwner() itself was returning a nullptr.