Shader loading: prevent dereferencing potential nullptr when file is not found

I’d like to highlight this pull request I’m opening: https://github.com/EpicGames/UnrealEngine/pull/13628

Loading shaders (for eg: through a niagara custom hlsl node include) with incorrect name, can result in the LocalFileContents to be a nullptr. It’s therefore unsafe to dereference it.

This PR catching this case.

Steps to Reproduce
Have a niagara system, with a custom HLSL node, that includes a shader header file that doesn’t exist.

The engine will crash, on de-referencing LocalFileContents and then trying to access it later.

Thanks Quentin, I’ll make sure to integrate this.

Hey Stu :slight_smile: Nice one!

btw, I also picked up on another issue, but didn’t spend time trying to get to the bottom of it.

If a niagara custom hlsl node, includes a .ush file, and that .ush file, includes another header - which doesn’t exist (ie: typo or genuinely isn’t there), the Niagara system gets stuck “compiling”, and never completes. It’s actually a soft lock, as you can’t save the NS without finishing compilation, and nothing tells you it’s caused by the invalid header include.

Hopefully that’s enough repro steps

Thanks, I’ll see if QA can repro that one for us.