]> git.lizzy.rs Git - rust.git/commitdiff
Copy undef_masks correctly for repeated bytes
authorWesley Wiser <wwiser@gmail.com>
Sat, 30 Jun 2018 18:23:41 +0000 (14:23 -0400)
committerWesley Wiser <wwiser@gmail.com>
Sat, 30 Jun 2018 19:20:10 +0000 (15:20 -0400)
src/librustc_mir/interpret/memory.rs

index 8aff58e09bae1c67eef0bd0119ef77594984cf68..bf720540bdcd40ba93742c19c0ba6a6140695d4b 100644 (file)
@@ -666,7 +666,7 @@ pub fn copy_repeatedly(
             }
         }
 
-        self.copy_undef_mask(src, dest, size * length)?;
+        self.copy_undef_mask(src, dest, size, length)?;
         // copy back the relocations
         self.get_mut(dest.alloc_id)?.relocations.insert_presorted(relocations);
 
@@ -887,6 +887,7 @@ fn copy_undef_mask(
         src: Pointer,
         dest: Pointer,
         size: Size,
+        repeat: u64,
     ) -> EvalResult<'tcx> {
         // The bits have to be saved locally before writing to dest in case src and dest overlap.
         assert_eq!(size.bytes() as usize as u64, size.bytes());
@@ -896,10 +897,13 @@ fn copy_undef_mask(
 
         for i in 0..size.bytes() {
             let defined = undef_mask.get(src.offset + Size::from_bytes(i));
-            dest_allocation.undef_mask.set(
-                dest.offset + Size::from_bytes(i),
-                defined
-            );
+            
+            for j in 0..repeat {
+                dest_allocation.undef_mask.set(
+                    dest.offset + Size::from_bytes(i + (size.bytes() * j)),
+                    defined
+                );
+            }
         }
 
         Ok(())