From 1b3b9194c054ce5cc9e788ded256f826f815eb96 Mon Sep 17 00:00:00 2001 From: bd_ Date: Tue, 13 Aug 2024 20:32:52 -0700 Subject: [PATCH] fix: use-after-free issue in NativeMemoryManager (#1006) Closes: #1001 --- Runtime/ArmatureAwase/NativeMemoryManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Runtime/ArmatureAwase/NativeMemoryManager.cs b/Runtime/ArmatureAwase/NativeMemoryManager.cs index dcd909a8..eaf6ae43 100644 --- a/Runtime/ArmatureAwase/NativeMemoryManager.cs +++ b/Runtime/ArmatureAwase/NativeMemoryManager.cs @@ -97,7 +97,10 @@ namespace nadena.dev.modular_avatar.core.armature_lock }; arrays.Add(InUseMask); - _allocationMap.OnSegmentDispose += seg => { SetInUseMask(seg.Offset, seg.Length, false); }; + _allocationMap.OnSegmentDispose += seg => + { + if (!_isDisposed) SetInUseMask(seg.Offset, seg.Length, false); + }; } public NativeArrayRef CreateArray() where T : unmanaged