From 318e4af9556544caa6df0bf6e20fee0fb8ef1a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luke=20Sern=C3=A9?= Date: Sun, 19 May 2024 23:03:42 +0200 Subject: [PATCH] Decompiler: Fix float comparison inputs swap in rule subflow_convert The decompiler rule `subflow_convert` would sometimes swap the inputs to the P-Code ops `FLOAT_LESS` and `FLOAT_LESSEQUAL` if the float that was traced happened to be the second input of the operation, because the transformed operation had its inputs hardcoded: the traced float would always be the first input. While this also affected `FLOAT_EQUAL` and `FLOAT_NOTEQUAL`, it does not matter in those cases, because swapping the inputs for those operations is still logically equivalent. Fixes #6528. --- Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc index bde73ee843..966d805677 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc @@ -2652,8 +2652,8 @@ bool SubfloatFlow::traceForward(TransformVar *rvn) } if (preexistingGuard(slot, rvn2)) { TransformOp *rop = newPreexistingOp(2, op->code(), op); - opSetInput(rop, rvn, 0); - opSetInput(rop, rvn2, 1); + opSetInput(rop, rvn, slot); + opSetInput(rop, rvn2, 1 - slot); terminatorCount += 1; } break;