File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ pub struct MiriAllocBytes {
14
14
layout : alloc:: Layout ,
15
15
/// Pointer to the allocation contents.
16
16
/// Invariant:
17
- /// * If `self.layout.size() == 0`, then `self.ptr` is some suitably aligned pointer
18
- /// that was allocated with the same layout but `size == 1`.
17
+ /// * If `self.layout.size() == 0`, then `self.ptr` was allocated with the equivalent layout with size 1.
19
18
/// * Otherwise, `self.ptr` points to memory allocated with `self.layout`.
20
19
ptr : * mut u8 ,
21
20
}
@@ -30,6 +29,8 @@ impl Clone for MiriAllocBytes {
30
29
31
30
impl Drop for MiriAllocBytes {
32
31
fn drop ( & mut self ) {
32
+ // We have to reconstruct the actual layout used for allocation.
33
+ // (`Deref` relies on `size` so we can't just always set it to at least 1.)
33
34
let alloc_layout = if self . layout . size ( ) == 0 {
34
35
Layout :: from_size_align ( 1 , self . layout . align ( ) ) . unwrap ( )
35
36
} else {
You can’t perform that action at this time.
0 commit comments