]> git.lizzy.rs Git - rust.git/commitdiff
interpret: clobber return place when calling function
authorRalf Jung <post@ralfj.de>
Sat, 3 Dec 2022 12:33:00 +0000 (13:33 +0100)
committerRalf Jung <post@ralfj.de>
Sat, 3 Dec 2022 12:37:13 +0000 (13:37 +0100)
compiler/rustc_const_eval/src/interpret/eval_context.rs

index 79450fccfc4d8567e377320463034e0ebef3f15d..e17d3e516a64fb72ae438726e275956340bb2e24 100644 (file)
@@ -676,6 +676,10 @@ pub fn push_stack_frame(
         return_to_block: StackPopCleanup,
     ) -> InterpResult<'tcx> {
         trace!("body: {:#?}", body);
+        // Clobber previous return place contents, nobody is supposed to be able to see them any more
+        // This also checks dereferenceable, but not align. We rely on all constructed places being
+        // sufficiently aligned (in particular we rely on `deref_operand` checking alignment).
+        self.write_uninit(return_place)?;
         // first push a stack frame so we have access to the local substs
         let pre_frame = Frame {
             body,