UCaptureManagerEditorSettings - dangling lambda

Hi Epic. This isn’t an actual question - more of an FYI. Thanks to Stomp2Malloc, I noticed that UCaptureManagerEditorSettings never removes its OnModularFeatureUnregistered lambda. When the editor exits, the dangling ‘this’ pointer captured by the lambda is being accessed, after UCaptureManagerEditorSettings has been destroyed.

It’s an easy fix. I added this method:

void UCaptureManagerEditorSettings::Destroy()
{
	IModularFeatures::Get().OnModularFeatureUnregistered().Remove(OnModularFeatureUnregisteredHandle);
}

Combined with:

OnModularFeatureUnregisteredHandle = IModularFeatures::Get().OnModularFeatureUnregistered().AddLambda(…

and…

void FCaptureManagerEditorSettingsModule::EnginePreExit()
{
	UCaptureManagerEditorSettings* Settings = GetMutableDefault<UCaptureManagerEditorSettings>();
	check(Settings);
	Settings->Destroy();
	...

That’s it :slightly_smiling_face:. It would be good if you adopted this fix, so everyone will benefit, but also future merges of UE will be less painful on our side.

Thanks.

Steps to Reproduce
Load the editor with:

-stomp2malloc -MallocStomp2MaxSize=9999999

(See [Content removed] first!)

Then close the editor. Stomp2Malloc will report the issue.

Hey Kostas, I submitted a speculative fix (I could not get an editor with Stomp2Malloc to boot in my stream). The fix which landed in 46527263 (UE5 Main), it will also be in the 5.7 release.