From 82e2144ed74648485dc27dbb67f594acd1b14916 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 6 May 2024 09:45:11 +0200 Subject: [PATCH] avoid code duplication between realloc and malloc --- src/tools/miri/src/shims/alloc.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/tools/miri/src/shims/alloc.rs b/src/tools/miri/src/shims/alloc.rs index 79531598c003..61e639f76ed9 100644 --- a/src/tools/miri/src/shims/alloc.rs +++ b/src/tools/miri/src/shims/alloc.rs @@ -124,13 +124,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let new_align = this.min_align(new_size, kind); if this.ptr_is_null(old_ptr)? { // Here we must behave like `malloc`. - if new_size == 0 { - Ok(Pointer::null()) - } else { - let new_ptr = - this.allocate_ptr(Size::from_bytes(new_size), new_align, kind.into())?; - Ok(new_ptr.into()) - } + self.malloc(new_size, /*zero_init*/ false, kind) } else { if new_size == 0 { // C, in their infinite wisdom, made this UB.