File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -241,13 +241,11 @@ impl Layout {
241241 #[ unstable( feature = "alloc_layout_extra" , issue = "55724" ) ]
242242 #[ inline]
243243 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 ( ) ) ;
251249 let alloc_size = padded_size. checked_mul ( n) . ok_or ( LayoutErr { private : ( ) } ) ?;
252250
253251 unsafe {
You can’t perform that action at this time.
0 commit comments