1
1
use std:: collections:: hash_map:: Entry ;
2
2
use std:: io:: Write ;
3
- use std:: iter;
4
3
use std:: path:: Path ;
5
4
6
5
use rustc_abi:: { Align , AlignFromBytesError , Size } ;
@@ -9,6 +8,7 @@ use rustc_ast::expand::allocator::alloc_error_handler_name;
9
8
use rustc_hir:: def:: DefKind ;
10
9
use rustc_hir:: def_id:: CrateNum ;
11
10
use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
11
+ use rustc_middle:: mir:: interpret:: AllocInit ;
12
12
use rustc_middle:: ty:: Ty ;
13
13
use rustc_middle:: { mir, ty} ;
14
14
use rustc_span:: Symbol ;
@@ -442,7 +442,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
442
442
let [ size] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
443
443
let size = this. read_target_usize ( size) ?;
444
444
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 ) ?;
446
446
this. write_pointer ( res, dest) ?;
447
447
} else {
448
448
// 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> {
457
457
let items = this. read_target_usize ( items) ?;
458
458
let elem_size = this. read_target_usize ( elem_size) ?;
459
459
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 ) ?;
461
461
this. write_pointer ( res, dest) ?;
462
462
} else {
463
463
// On size overflow, return null and, on Unix, set errno.
@@ -509,6 +509,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
509
509
Size :: from_bytes ( size) ,
510
510
Align :: from_bytes ( align) . unwrap ( ) ,
511
511
memory_kind. into ( ) ,
512
+ AllocInit :: Uninit
512
513
) ?;
513
514
514
515
ecx. write_pointer ( ptr, dest)
@@ -537,14 +538,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
537
538
Size :: from_bytes ( size) ,
538
539
Align :: from_bytes ( align) . unwrap ( ) ,
539
540
MiriMemoryKind :: Rust . into ( ) ,
541
+ AllocInit :: Zero
540
542
) ?;
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 ( ) ;
548
543
this. write_pointer ( ptr, dest)
549
544
} ) ;
550
545
}
@@ -604,6 +599,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
604
599
Size :: from_bytes ( new_size) ,
605
600
align,
606
601
MiriMemoryKind :: Rust . into ( ) ,
602
+ AllocInit :: Uninit
607
603
) ?;
608
604
this. write_pointer ( new_ptr, dest)
609
605
} ) ;
0 commit comments