11use std:: collections:: hash_map:: Entry ;
22use std:: io:: Write ;
3- use std:: iter;
43use std:: path:: Path ;
54
65use rustc_abi:: { Align , AlignFromBytesError , Size } ;
@@ -9,6 +8,7 @@ use rustc_ast::expand::allocator::alloc_error_handler_name;
98use rustc_hir:: def:: DefKind ;
109use rustc_hir:: def_id:: CrateNum ;
1110use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
11+ use rustc_middle:: mir:: interpret:: AllocInit ;
1212use rustc_middle:: ty:: Ty ;
1313use rustc_middle:: { mir, ty} ;
1414use rustc_span:: Symbol ;
@@ -442,7 +442,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
442442 let [ size] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
443443 let size = this. read_target_usize ( size) ?;
444444 if size <= this. max_size_of_val ( ) . bytes ( ) {
445- let res = this. malloc ( size, /*zero_init:*/ false ) ?;
445+ let res = this. malloc ( size, AllocInit :: Uninit ) ?;
446446 this. write_pointer ( res, dest) ?;
447447 } else {
448448 // If this does not fit in an isize, return null and, on Unix, set errno.
@@ -457,7 +457,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
457457 let items = this. read_target_usize ( items) ?;
458458 let elem_size = this. read_target_usize ( elem_size) ?;
459459 if let Some ( size) = this. compute_size_in_bytes ( Size :: from_bytes ( elem_size) , items) {
460- let res = this. malloc ( size. bytes ( ) , /*zero_init:*/ true ) ?;
460+ let res = this. malloc ( size. bytes ( ) , AllocInit :: Zero ) ?;
461461 this. write_pointer ( res, dest) ?;
462462 } else {
463463 // On size overflow, return null and, on Unix, set errno.
@@ -509,6 +509,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
509509 Size :: from_bytes ( size) ,
510510 Align :: from_bytes ( align) . unwrap ( ) ,
511511 memory_kind. into ( ) ,
512+ AllocInit :: Uninit
512513 ) ?;
513514
514515 ecx. write_pointer ( ptr, dest)
@@ -537,14 +538,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
537538 Size :: from_bytes ( size) ,
538539 Align :: from_bytes ( align) . unwrap ( ) ,
539540 MiriMemoryKind :: Rust . into ( ) ,
541+ AllocInit :: Zero
540542 ) ?;
541-
542- // We just allocated this, the access is definitely in-bounds.
543- this. write_bytes_ptr (
544- ptr. into ( ) ,
545- iter:: repeat ( 0u8 ) . take ( usize:: try_from ( size) . unwrap ( ) ) ,
546- )
547- . unwrap ( ) ;
548543 this. write_pointer ( ptr, dest)
549544 } ) ;
550545 }
@@ -604,6 +599,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
604599 Size :: from_bytes ( new_size) ,
605600 align,
606601 MiriMemoryKind :: Rust . into ( ) ,
602+ AllocInit :: Uninit
607603 ) ?;
608604 this. write_pointer ( new_ptr, dest)
609605 } ) ;
0 commit comments