Skip to content

Commit cb55ce1

Browse files
committed
Fix potential crash on large constant ZST slice
1 parent ca18301 commit cb55ce1

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/constant.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ pub(crate) fn codegen_const_value<'tcx>(
186186
ConstValue::Slice { data, meta } => {
187187
let alloc_id = fx.tcx.reserve_and_set_memory_alloc(data);
188188
let ptr = pointer_for_allocation(fx, alloc_id).get_addr(fx);
189-
// FIXME: the `try_from` here can actually fail, e.g. for very long ZST slices.
190-
let len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(meta).unwrap());
189+
let len = fx.bcx.ins().iconst(fx.pointer_type, meta as i64);
191190
CValue::by_val_pair(ptr, len, layout)
192191
}
193192
}

0 commit comments

Comments
 (0)