Developer Notes

Intended behavior is to check for Null reference before use

Description

Making a call to GetPawn in an AIController class will return NULL which will crash when that return value is used.

This is a regression as the call is made successfully in 4.8.3.

Working CL:
Worked in 4.8.3 (4.8.0 branched in CL 2577408)

Broken CL:
Broken in 4.9 (Branched in CL 2624401)

Steps to Reproduce

1. Open UE4 Editor (third person code template)
2. Create class based on AIController (MyAIController)
3. Add the following to MyAIController.h

FRotator GetControlRotation() const override;

4. Add the following to MyAIController.cpp

FRotator AMyAIController::GetControlRotation() const
{
	GetPawn()->GetActorClass(); // call some function from 
	// GetPawn to throw a nullexecption
	return ControlRotation;
}

5. Put a breakpoint on the GetPawn() line and press F5 to compile
6. In the editor create a blueprint based on character (NewCharBP)
7. In the details panel set AI Controller class to MyAIController
8. Place instance of NewCharBP into the level
9. PIE

Result:
Breakpoint will trigger on PIE. Stepping into the function will show that the character is Null when the call to GetClass() is made.

Expected:
In 4.8 the correct blueprint was set when GetPawn() was called.

Have Comments or More Details?

Head over to the existing Questions & Answers thread and let us know what's up.

0
Login to Vote

Won't Fix
ComponentUE - Gameplay
Affects Versions4.9
CreatedSep 3, 2015
ResolvedSep 5, 2015
UpdatedJul 14, 2021
View Jira Issue