Skip to content

Commit bfe04e0

Browse files
committed
Fix deallocation with wrong allocator in (A)Rc::from_box_in
1 parent ae9d24d commit bfe04e0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

library/alloc/src/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
19241924

19251925
// Free the allocation without dropping its contents
19261926
let (bptr, alloc) = Box::into_raw_with_allocator(src);
1927-
let src = Box::from_raw(bptr as *mut mem::ManuallyDrop<T>);
1927+
let src = Box::from_raw_in(bptr as *mut mem::ManuallyDrop<T>, alloc.by_ref());
19281928
drop(src);
19291929

19301930
Self::from_ptr_in(ptr, alloc)

library/alloc/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
18691869

18701870
// Free the allocation without dropping its contents
18711871
let (bptr, alloc) = Box::into_raw_with_allocator(src);
1872-
let src = Box::from_raw(bptr as *mut mem::ManuallyDrop<T>);
1872+
let src = Box::from_raw_in(bptr as *mut mem::ManuallyDrop<T>, alloc.by_ref());
18731873
drop(src);
18741874

18751875
Self::from_ptr_in(ptr, alloc)

0 commit comments

Comments
 (0)