about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCAD97 <cad97@cad97.com>2020-12-29 15:42:41 -0500
committerCAD97 <cad97@cad97.com>2020-12-29 15:42:41 -0500
commit81685e9ad8f80634f0dfd7c1afcab74ba1c78a59 (patch)
tree6eaab13e6426ce592d0c7f1bf17f55fdfed2f6c6
parent158f8d034b15e65ba8dc0d066358dd0632bfcd6e (diff)
downloadrust-81685e9ad8f80634f0dfd7c1afcab74ba1c78a59.tar.gz
rust-81685e9ad8f80634f0dfd7c1afcab74ba1c78a59.zip
Do not create dangling &T in Weak<T>::drop
-rw-r--r--library/alloc/src/rc.rs2
-rw-r--r--library/alloc/src/sync.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs
index 73d12f0a5f4..57df28a15c8 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -2042,7 +2042,7 @@ impl<T: ?Sized> Drop for Weak<T> {
         // the strong pointers have disappeared.
         if inner.weak() == 0 {
             unsafe {
-                Global.deallocate(self.ptr.cast(), Layout::for_value(self.ptr.as_ref()));
+                Global.deallocate(self.ptr.cast(), Layout::for_value_raw(self.ptr.as_ptr()));
             }
         }
     }
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs
index 7c03345aba5..85c0a9f0857 100644
--- a/library/alloc/src/sync.rs
+++ b/library/alloc/src/sync.rs
@@ -1927,7 +1927,7 @@ impl<T: ?Sized> Drop for Weak<T> {
 
         if inner.weak.fetch_sub(1, Release) == 1 {
             acquire!(inner.weak);
-            unsafe { Global.deallocate(self.ptr.cast(), Layout::for_value(self.ptr.as_ref())) }
+            unsafe { Global.deallocate(self.ptr.cast(), Layout::for_value_raw(self.ptr.as_ptr())) }
         }
     }
 }