about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-12-03 13:33:00 +0100
committerRalf Jung <post@ralfj.de>2022-12-03 13:37:13 +0100
commit51ac2af99ffd46cf83760ceef2404dad0ce238a9 (patch)
tree6c5af372c5d657aca3e2412449018df1a98c4670 /compiler
parent11663b1b4857ffeafbd85a9a36c234d117373b76 (diff)
downloadrust-51ac2af99ffd46cf83760ceef2404dad0ce238a9.tar.gz
rust-51ac2af99ffd46cf83760ceef2404dad0ce238a9.zip
interpret: clobber return place when calling function
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_const_eval/src/interpret/eval_context.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs
index 79450fccfc4..e17d3e516a6 100644
--- a/compiler/rustc_const_eval/src/interpret/eval_context.rs
+++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs
@@ -676,6 +676,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
         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,