When Calling UBlueprintMapLibrary::GenericMap_Find with a non-existent key, the function construct the default structure in-place on the given pointer without destroying the object.
This behavior causes a memory leak.
The following fix works :
bool UBlueprintMapLibrary::GenericMap_Find(const void* TargetMap, const FMapProperty* MapProperty, const void* KeyPtr, void* OutValuePtr) { if(TargetMap) { FScriptMapHelper MapHelper(MapProperty, TargetMap); uint8* FoundValuePtr = MapHelper.FindValueFromHash(KeyPtr); if (OutValuePtr) { if (FoundValuePtr) { MapProperty->ValueProp->CopyCompleteValueFromScriptVM(OutValuePtr, FoundValuePtr); } else { #if 1 //fix for it MapProperty->ValueProp->ClearValue(OutValuePtr); #else MapProperty->ValueProp->InitializeValue(OutValuePtr); #endif } } return FoundValuePtr != nullptr; } return false; }
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-272934 in the post.
1 |
Component | UE - Framework - Blueprint |
---|---|
Affects Versions | 5.5 |
Created | Apr 15, 2025 |
---|---|
Updated | Apr 17, 2025 |