From f6d83f47d9d3730af9d10932147ab9e3b0120d5d Mon Sep 17 00:00:00 2001 From: Kyle Date: Mon, 6 Oct 2025 11:54:29 +0800 Subject: [PATCH] Fix memory management in DynamicPropertyBuffer item transfer Use move() instead of pointee when transferring items between buffers to properly transfer ownership and avoid potential memory issues. (Current they are the same since Item is a fixed POD type) --- .../Data/DynamicProperty/DynamicPropertyBuffer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicPropertyBuffer.swift b/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicPropertyBuffer.swift index e5a8b6898..2574604ff 100644 --- a/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicPropertyBuffer.swift +++ b/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicPropertyBuffer.swift @@ -396,7 +396,7 @@ public struct _DynamicPropertyBuffer { while count > 0 { let newItemPointer = newBuffer.assumingMemoryBound(to: Item.self) let oldItemPointer = oldBuffer.assumingMemoryBound(to: Item.self) - newItemPointer.initialize(to: oldItemPointer.pointee) + newItemPointer.initialize(to: oldItemPointer.move()) oldItemPointer.pointee.vtable.moveInitialize( ptr: newBuffer.advanced(by: MemoryLayout.size), from: oldBuffer.advanced(by: MemoryLayout.size)