Unreal Engine 5 plugin component for rendering runtime generated content.
1.58k
stars
412
forks
source link
Wrong iterator for FRuntimeMeshLOD::Sections TMap cause crash for sectionIds of non sequential or large values #190
Closed
Alex-Folts closed 4 years ago
So here: https://github.com/KoderzUnreal/RuntimeMeshComponent/blob/1c8a9d261c6d074e2731ec8474d6ec05d3356ecb/Source/RuntimeMeshComponent/Private/RuntimeMesh.cpp#L1152 you iterating through
TMap
using for loop, the problem is if section have 1 element and its id != 0, it will try to acessTMap
element with key = 0(look for loop above), and will crash. I.e. if you create sections out of order or just create it with some random Id - you will got crash.Assertion failed: Pair != nullptr [File:C:\Program Files\Epic Games\UE_4.23\Engine\Source\Runtime\Core\Public\Containers/Map.h] [Line: 508]
This is one of proper ways of iterating through TMap: https://answers.unrealengine.com/questions/814439/how-to-iterate-through-a-tmap-via-range-based-for.html
To reproduse bug, just call CreateSection with section id of some large number(even 1 will work if its first section). I'm using UE_4.23.
I was changed code of
RuntimeMesh.cpp
like so and it seems work now: