File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -241,13 +241,11 @@ impl Layout {
241
241
#[ unstable( feature = "alloc_layout_extra" , issue = "55724" ) ]
242
242
#[ inline]
243
243
pub fn repeat ( & self , n : usize ) -> Result < ( Self , usize ) , LayoutErr > {
244
- // Warning, removing the checked_add here led to segfaults in #67174. Further
245
- // analysis in #69225 seems to indicate that this is an LTO-related
246
- // miscompilation, so #67174 might be able to be reapplied in the future.
247
- let padded_size = self
248
- . size ( )
249
- . checked_add ( self . padding_needed_for ( self . align ( ) ) )
250
- . ok_or ( LayoutErr { private : ( ) } ) ?;
244
+ // This cannot overflow. Quoting from the invariant of Layout:
245
+ // > `size`, when rounded up to the nearest multiple of `align`,
246
+ // > must not overflow (i.e., the rounded value must be less than
247
+ // > `usize::MAX`)
248
+ let padded_size = self . size ( ) + self . padding_needed_for ( self . align ( ) ) ;
251
249
let alloc_size = padded_size. checked_mul ( n) . ok_or ( LayoutErr { private : ( ) } ) ?;
252
250
253
251
unsafe {
You can’t perform that action at this time.
0 commit comments