...
Code Block | ||||
---|---|---|---|---|
| ||||
auto g(int val) { auto outer = [val] { int i = val; auto inner = [&] { i += 30; return i; }; return inner; }; return outer(); } void f() { auto fn = g(12); int ij = fn(); } |
Compliant Solution
...
Code Block | ||||
---|---|---|---|---|
| ||||
auto g(int val) { auto outer = [val] { int i = val; auto inner = [i] { return i + 30; }; return inner; }; return outer(); } void f() { auto fn = g(12); int ij = fn(); } |
Risk Assessment
Referencing an object outside of its lifetime can result in an attacker being able to run arbitrary code.
...