Fix potential crash on large constant ZST slice
This commit is contained in:
parent
ca18301dfe
commit
cb55ce11dc
@ -186,8 +186,7 @@ pub(crate) fn codegen_const_value<'tcx>(
|
||||
ConstValue::Slice { data, meta } => {
|
||||
let alloc_id = fx.tcx.reserve_and_set_memory_alloc(data);
|
||||
let ptr = pointer_for_allocation(fx, alloc_id).get_addr(fx);
|
||||
// FIXME: the `try_from` here can actually fail, e.g. for very long ZST slices.
|
||||
let len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(meta).unwrap());
|
||||
let len = fx.bcx.ins().iconst(fx.pointer_type, meta as i64);
|
||||
CValue::by_val_pair(ptr, len, layout)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user