Skip to content

Commit

Permalink
read_c_str should call the AllocationExtra hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 25, 2018
1 parent 37961db commit af54eb2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/librustc/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
}
Expand Down

0 comments on commit af54eb2

Please sign in to comment.