Everywhere: Fix incorrect usages of AK::Checked

Specifically, explicitly specify the checked type, use the resulting
value instead of doing the same calculation twice, and break down
calculations to discrete operations to ensure no intermediary overflows
are missed.
This commit is contained in:
Idan Horowitz 2021-07-04 20:23:26 +03:00 committed by Linus Groh
commit 301c1a3a58
Notes: sideshowbarker 2024-07-18 10:27:40 +09:00
6 changed files with 16 additions and 15 deletions

View file

@ -191,7 +191,7 @@ void BytecodeInterpreter::call_address(Configuration& configuration, FunctionAdd
TRAP_IF_NOT(rhs.has_value()); \
dbgln_if(WASM_TRACE_DEBUG, "{} {} {} = ??", ulhs.value(), #operator, rhs.value()); \
__VA_ARGS__; \
Checked lhs = ulhs.value(); \
Checked<type> lhs = ulhs.value(); \
lhs operator##= rhs.value(); \
TRAP_IF_NOT(!lhs.has_overflow()); \
auto result = lhs.value(); \