From 7a6010e7dc6492ab16d18d07bf5bfe60b85fb152 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 5 Jul 2022 11:12:18 +0200 Subject: [PATCH] Fix unsafe memory access when converting entity handles --- crates/gpui/src/app.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index ad38520032..8a67351c44 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -4451,7 +4451,7 @@ impl AnyViewHandle { handle_id: self.handle_id, }); unsafe { - Arc::decrement_strong_count(&self.ref_counts); + Arc::decrement_strong_count(Arc::as_ptr(&self.ref_counts)); } std::mem::forget(self); result @@ -4517,8 +4517,9 @@ impl From> for AnyViewHandle { #[cfg(any(test, feature = "test-support"))] handle_id: handle.handle_id, }; + unsafe { - Arc::decrement_strong_count(&handle.ref_counts); + Arc::decrement_strong_count(Arc::as_ptr(&handle.ref_counts)); } std::mem::forget(handle); any_handle @@ -4580,7 +4581,7 @@ impl AnyModelHandle { handle_id: self.handle_id, }); unsafe { - Arc::decrement_strong_count(&self.ref_counts); + Arc::decrement_strong_count(Arc::as_ptr(&self.ref_counts)); } std::mem::forget(self); result