about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2018-11-25 10:56:10 +0100
committerRalf Jung <post@ralfj.de>2018-11-25 10:56:10 +0100
commitaf54eb2916b9f5707c7bfa577f5db29918870ce2 (patch)
treeaaa1d427e28c4f11561f26051eeb85784d60a016
parent37961dbd2d84a29be49007a5770b96e296f5f349 (diff)
downloadrust-af54eb2916b9f5707c7bfa577f5db29918870ce2.tar.gz
rust-af54eb2916b9f5707c7bfa577f5db29918870ce2.zip
read_c_str should call the AllocationExtra hooks
-rw-r--r--src/librustc/mir/interpret/allocation.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs
index c612d6ad1bb..406d41d3436 100644
--- a/src/librustc/mir/interpret/allocation.rs
+++ b/src/librustc/mir/interpret/allocation.rs
@@ -172,10 +172,9 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
         let offset = ptr.offset.bytes() as usize;
         match self.bytes[offset..].iter().position(|&c| c == 0) {
             Some(size) => {
-                let p1 = Size::from_bytes((size + 1) as u64);
-                self.check_relocations(cx, ptr, p1)?;
-                self.check_defined(ptr, p1)?;
-                Ok(&self.bytes[offset..offset + size])
+                let size = Size::from_bytes((size + 1) as u64);
+                // Go through `get_bytes` for checks and AllocationExtra hooks
+                self.get_bytes(cx, ptr, size)
             }
             None => err!(UnterminatedCString(ptr.erase_tag())),
         }