diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-09-26 16:52:08 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-09-26 16:52:08 +0000 |
| commit | cb55ce11dc86c288f3d0e2b7ada3db9364997893 (patch) | |
| tree | c85bb6a20b60e5b4221a8379b2ba29c1df5d1c41 | |
| parent | ca18301dfea63a041735aa146b74e61ab204180e (diff) | |
| download | rust-cb55ce11dc86c288f3d0e2b7ada3db9364997893.tar.gz rust-cb55ce11dc86c288f3d0e2b7ada3db9364997893.zip | |
Fix potential crash on large constant ZST slice
| -rw-r--r-- | src/constant.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/constant.rs b/src/constant.rs index 653c5b93573..1cb6fa07723 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -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) } } |
