diff --git a/OpenDreamRuntime/Objects/DreamObject.cs b/OpenDreamRuntime/Objects/DreamObject.cs index cfa73be66b..646a14e50c 100644 --- a/OpenDreamRuntime/Objects/DreamObject.cs +++ b/OpenDreamRuntime/Objects/DreamObject.cs @@ -145,6 +145,8 @@ public void Delete(bool possiblyThreaded = false) { } public bool IsSubtypeOf(TreeEntry ancestor) { + if(Deleted) //null deref protection, deleted objects don't have ObjectDefinition anymore + return false; return ObjectDefinition.IsSubtypeOf(ancestor); } diff --git a/OpenDreamRuntime/Procs/DreamEnumerators.cs b/OpenDreamRuntime/Procs/DreamEnumerators.cs index b954ea507b..2deed0149e 100644 --- a/OpenDreamRuntime/Procs/DreamEnumerators.cs +++ b/OpenDreamRuntime/Procs/DreamEnumerators.cs @@ -47,6 +47,10 @@ public DreamObjectEnumerator(IEnumerable dreamObjects, TreeEntry? f public bool Enumerate(DMProcState state, DreamReference? reference) { bool success = _dreamObjectEnumerator.MoveNext(); + + while(success && _dreamObjectEnumerator.Current.Deleted) //skip over deleted + success = _dreamObjectEnumerator.MoveNext(); + if (_filterType != null) { while (success && !_dreamObjectEnumerator.Current.IsSubtypeOf(_filterType)) { success = _dreamObjectEnumerator.MoveNext();