Skip to content

Commit af54eb2

Browse files
committed
read_c_str should call the AllocationExtra hooks
1 parent 37961db commit af54eb2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/librustc/mir/interpret/allocation.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,9 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
172172
let offset = ptr.offset.bytes() as usize;
173173
match self.bytes[offset..].iter().position(|&c| c == 0) {
174174
Some(size) => {
175-
let p1 = Size::from_bytes((size + 1) as u64);
176-
self.check_relocations(cx, ptr, p1)?;
177-
self.check_defined(ptr, p1)?;
178-
Ok(&self.bytes[offset..offset + size])
175+
let size = Size::from_bytes((size + 1) as u64);
176+
// Go through `get_bytes` for checks and AllocationExtra hooks
177+
self.get_bytes(cx, ptr, size)
179178
}
180179
None => err!(UnterminatedCString(ptr.erase_tag())),
181180
}

0 commit comments

Comments
 (0)