Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion library/std/src/sys/alloc/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) {

// SAFETY: Because of the contract of `System`, `ptr` is guaranteed to be non-null
// and have a header readable directly before it.
unsafe { ptr::read((ptr as *mut Header).sub(1)).0 }
let block_ptr = unsafe { ptr::read((ptr as *mut Header).sub(1)).0 };
// Always deallocate using the provenance that was passed to us, not what we stored in
// the header. The passed-in provenance may be protected, for example because it is from
// a Box argument to mem::drop.
ptr.with_addr(block_ptr.addr())
}
};

Expand Down
Loading