[−][src]Function clear_on_drop::clear_stack_on_return
pub fn clear_stack_on_return<F, R>(pages: usize, f: F) -> R where
F: FnMut() -> R,
Calls a closure and overwrites its stack on return.
This function calls clear_stack
after calling the passed closure,
taking care to prevent either of them being inlined, so the stack
used by the closure will be overwritten with zeros (as long as a
large enough number of pages
is used).
For technical reasons, this function can be used only with Fn
or
FnMut
. If all you have is a FnOnce
, use the auxiliary function
clear_stack_on_return_fnonce
instead.
Example
let input = b"abc"; let result = clear_stack_on_return(1, || encrypt(input));