sway
sway copied to clipboard
Have a check on how the `__addr_of` intrinsic's result is used
It's possible that we have a contract that has a function taking in an address (u64
value).
contract;
abi Foo {
fn bar(addr: u64);
}
Then we have a script that calls this function bar
as below:
script;
use Foo::bar;
fn something() {
let x : b256 = 0x1111....;
let x_addr = __addr_of(x);
bar(x_addr);
}
This (using the address of a local variable in another program) should be statically analysed and disallowed as it violates memory safety (and causes a runtime failure).