@@ -23,8 +23,8 @@ use rustc_target::abi::{call::FnAbi, Align, HasDataLayout, Size, TargetDataLayou
2323
2424use super :: {
2525 AllocCheck , AllocId , GlobalId , Immediate , InterpErrorInfo , InterpResult , MPlaceTy , Machine ,
26- MemPlace , MemPlaceMeta , Memory , MemoryKind , Operand , Place , PlaceTy , Pointer , Provenance ,
27- Scalar , ScalarMaybeUninit , StackPopJump ,
26+ MemPlace , MemPlaceMeta , Memory , MemoryKind , Operand , Place , PlaceTy , Pointer ,
27+ PointerArithmetic , Provenance , Scalar , ScalarMaybeUninit , StackPopJump ,
2828} ;
2929use crate :: transform:: validate:: equal_up_to_regions;
3030
@@ -678,7 +678,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
678678 let size = size. align_to ( align) ;
679679
680680 // Check if this brought us over the size limit.
681- if size. bytes ( ) >= self . tcx . data_layout . obj_size_bound ( ) {
681+ if size > self . max_size_of_val ( ) {
682682 throw_ub ! ( InvalidMeta ( "total size is bigger than largest supported object" ) ) ;
683683 }
684684 Ok ( Some ( ( size, align) ) )
@@ -694,9 +694,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
694694 let elem = layout. field ( self , 0 ) ;
695695
696696 // Make sure the slice is not too big.
697- let size = elem. size . checked_mul ( len, self ) . ok_or_else ( || {
698- err_ub ! ( InvalidMeta ( "slice is bigger than largest supported object" ) )
699- } ) ?;
697+ let size = elem. size * len;
698+ if size > self . max_size_of_val ( ) {
699+ throw_ub ! ( InvalidMeta ( "slice is bigger than largest supported object" ) ) ;
700+ }
700701 Ok ( Some ( ( size, elem. align . abi ) ) )
701702 }
702703
0 commit comments