Fix mir CString lowering not respecting the extra 0 byte for length calc
This commit is contained in:
parent
4b577e2bc8
commit
eab295cc73
@ -1121,11 +1121,13 @@ fn lower_literal_to_operand(&mut self, ty: Ty, l: &Literal) -> Result<Operand> {
|
||||
}
|
||||
hir_def::hir::Literal::CString(b) => {
|
||||
let b = b.as_bytes();
|
||||
let bytes = b.iter().copied().chain(iter::once(0)).collect::<Vec<_>>();
|
||||
|
||||
let mut data = Vec::with_capacity(mem::size_of::<usize>() * 2);
|
||||
data.extend(0usize.to_le_bytes());
|
||||
data.extend(b.len().to_le_bytes());
|
||||
data.extend(bytes.len().to_le_bytes());
|
||||
let mut mm = MemoryMap::default();
|
||||
mm.insert(0, b.iter().copied().chain(iter::once(0)).collect::<Vec<_>>());
|
||||
mm.insert(0, bytes);
|
||||
return Ok(Operand::from_concrete_const(data, mm, ty));
|
||||
}
|
||||
hir_def::hir::Literal::ByteString(b) => {
|
||||
|
Loading…
Reference in New Issue
Block a user