From 38df70f4bc44fcbf25d733cf8ea91bfe28dd3d5a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 17 Oct 2020 12:08:55 +0200 Subject: [PATCH] - clear intermediate entries when inserting an object beyond the end of an array. --- src/common/scripting/core/dynarrays.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/scripting/core/dynarrays.cpp b/src/common/scripting/core/dynarrays.cpp index 82dd8e774..3d8e87e85 100644 --- a/src/common/scripting/core/dynarrays.cpp +++ b/src/common/scripting/core/dynarrays.cpp @@ -880,8 +880,10 @@ DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Delete, ArrayDelete) void ObjArrayInsert(FDynArray_Obj *self,int index, DObject *obj) { + int oldSize = self->Size(); GC::WriteBarrier(obj); self->Insert(index, obj); + for (unsigned i = oldSize; i < self->Size() - 1; i++) (*self)[i] = nullptr; } DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Insert, ObjArrayInsert)