Improve safety of ForLoopConditionTransformer

Desetude noticed that there are some cases where this transformation is
unsafe - for example: `i > i++`. Skipping the transform if _either_ side
of the comparison has a side effect, rather than _both_ sides, makes it
safe.
bzip2
Graham 5 years ago
parent b611854dbc
commit 784b14b66b
  1. 2
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ForLoopConditionTransformer.kt

@ -16,7 +16,7 @@ class ForLoopConditionTransformer : Transformer() {
}
val expr = compare.asBinaryExpr()
if (expr.left.hasSideEffects() && expr.right.hasSideEffects()) {
if (expr.hasSideEffects()) {
return@ifPresent
}

Loading…
Cancel
Save