File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ pub struct MiriAllocBytes {
1414     layout :  alloc:: Layout , 
1515    /// Pointer to the allocation contents. 
1616     /// 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. 
1918     /// * Otherwise, `self.ptr` points to memory allocated with `self.layout`. 
2019     ptr :  * mut  u8 , 
2120} 
@@ -30,6 +29,8 @@ impl Clone for MiriAllocBytes {
3029
3130impl  Drop  for  MiriAllocBytes  { 
3231    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.) 
3334        let  alloc_layout = if  self . layout . size ( )  == 0  { 
3435            Layout :: from_size_align ( 1 ,  self . layout . align ( ) ) . unwrap ( ) 
3536        }  else  { 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments