about summary refs log tree commit diff
diff options
context:
space:
mode:
authorzachs18 <8355914+zachs18@users.noreply.github.com>2024-01-09 16:46:45 -0600
committerZachary S <zasample18+github@gmail.com>2024-01-10 02:17:47 -0600
commitbfe04e08c04e2c332eb759d9ae8c5d53144b72b8 (patch)
tree7f9543fb85e415bac010c0de668d5c422a3920bd
parentae9d24de80b00b4158d1a29a212a6b02aeda0e75 (diff)
downloadrust-bfe04e08c04e2c332eb759d9ae8c5d53144b72b8.tar.gz
rust-bfe04e08c04e2c332eb759d9ae8c5d53144b72b8.zip
Fix deallocation with wrong allocator in (A)Rc::from_box_in
-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 263b1449de1..f986df05846 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -1924,7 +1924,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
 
             // Free the allocation without dropping its contents
             let (bptr, alloc) = Box::into_raw_with_allocator(src);
-            let src = Box::from_raw(bptr as *mut mem::ManuallyDrop<T>);
+            let src = Box::from_raw_in(bptr as *mut mem::ManuallyDrop<T>, alloc.by_ref());
             drop(src);
 
             Self::from_ptr_in(ptr, alloc)
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs
index 5273b3cb2da..dc82c9c4111 100644
--- a/library/alloc/src/sync.rs
+++ b/library/alloc/src/sync.rs
@@ -1869,7 +1869,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
 
             // Free the allocation without dropping its contents
             let (bptr, alloc) = Box::into_raw_with_allocator(src);
-            let src = Box::from_raw(bptr as *mut mem::ManuallyDrop<T>);
+            let src = Box::from_raw_in(bptr as *mut mem::ManuallyDrop<T>, alloc.by_ref());
             drop(src);
 
             Self::from_ptr_in(ptr, alloc)