Closed HaHarden closed 1 month ago
There is a logic error in de.fraunhofer.aisec.cpg.analysis.ValueEvaluator#handleConditionalExpression.
de.fraunhofer.aisec.cpg.analysis.ValueEvaluator#handleConditionalExpression
public void test() { int a = 1; a = a != 1 ? 2 : a; System.out.println(a); }
When outputting the value of reference 'a', it should equal 1, but the result is 2.
Oh, it looks like the value evaluator stupidly just compared the lhs (a) and rhs (1) of the condition using == regardless of the actual operator used 🙈
==
https://github.com/Fraunhofer-AISEC/cpg/blob/bb92f3eb1a51c6b2a7fa1a45df5dd2d0108dff1c/cpg-analysis/src/main/kotlin/de/fraunhofer/aisec/cpg/analysis/ValueEvaluator.kt#L365-L369
There is a logic error in
de.fraunhofer.aisec.cpg.analysis.ValueEvaluator#handleConditionalExpression
.testcase
When outputting the value of reference 'a', it should equal 1, but the result is 2.