mirror of
https://github.com/bevyengine/bevy.git
synced 2026-07-02 00:33:03 -04:00
85a87c4603
# Objective - `MovingPtr::assign_to` is currently unsound if the destructor of `*dst` panics because it will leave it populated with the old value whose destructor panicked. When the owner of `*dst` then drops it it will result in a double drop. - Fix this unsoundness, fixes #23500 ## Solution - Use a drop guard to ensure that no matter what happens when dropping `*dst`, it will be overwritten with the value from `self.` This has the same semantics as normal assignments except it will prevent generating multiple `memcpy`s. - ~~Rewrite the method to use a normal assignment to the reference so that the language itself takes care of this issue.~~ This ended up making two `memcpy`s ## Testing - A regression test has been added