@@ -23,8 +23,8 @@ use rustc_target::abi::{call::FnAbi, Align, HasDataLayout, Size, TargetDataLayou
23
23
24
24
use super :: {
25
25
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 ,
28
28
} ;
29
29
use crate :: transform:: validate:: equal_up_to_regions;
30
30
@@ -678,7 +678,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
678
678
let size = size. align_to ( align) ;
679
679
680
680
// 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 ( ) {
682
682
throw_ub ! ( InvalidMeta ( "total size is bigger than largest supported object" ) ) ;
683
683
}
684
684
Ok ( Some ( ( size, align) ) )
@@ -694,9 +694,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
694
694
let elem = layout. field ( self , 0 ) ;
695
695
696
696
// 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
+ }
700
701
Ok ( Some ( ( size, elem. align . abi ) ) )
701
702
}
702
703
0 commit comments