Memory crash using EmplaceAt

Hi,

You cannot ‘EmplaceAt’ or ‘Insert’ at an index greater than TArray<>::Count(). Since you have an array of pointers, you can add a couple of null elements first like below. Reserving the memory would possibly avoid reallocation, but this doesn’t construct the array ‘type’ item in the container.

if (Index > InventorySlots.Count()) { InventorySlots.AddDefaulted(Index - InventorySlots.Count()); } InventorySlots.EmplaceAt(Index, DuplicateObject<UTestObject>(DefaultSlot, this));Regards,

Patrick