about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/abi/stack-protector.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/ui/abi/stack-protector.rs b/tests/ui/abi/stack-protector.rs
index 24bd2e21943..e94aa816d90 100644
--- a/tests/ui/abi/stack-protector.rs
+++ b/tests/ui/abi/stack-protector.rs
@@ -40,6 +40,8 @@ fn vulnerable_function() {
     // Overwrite the on-stack return address with the address of `malicious_code()`,
     // thereby jumping to that function when returning from `vulnerable_function()`.
     unsafe { fill(stackaddr, bad_code_ptr, 20); }
+    // Capture the address, so the write is not optimized away.
+    std::hint::black_box(stackaddr);
 }
 
 // Use an uninlined function with its own stack frame to make sure that we don't