Skip to content

Gibbed.MadMax-1.5.4

Choose a tag to compare

@gigaHours gigaHours released this 19 Feb 17:47

Fix: Compiler missing trailing ret 0 sentinel

Bug: The compiler omitted the implicit ret 0 at the end of functions when the last statement was already a return. This caused jz/jmp labels targeting the end of the function to point past the last instruction (out-of-bounds). On subsequent decompilation, the CFG builder couldn't create a block for the invalid target, reducing a 2-successor jz block to 1 successor — which made the decompiler silently drop if guards.

Impact: Any function ending with if ...: return ... (no else) would lose the if condition on round-trip, turning conditional returns into unconditional ones.

Examples from enemy_boarding_gameplay.xvmc:

  • GetPositionSB — third if 1.0 == GetStateBit(char, 22.0): return 22.0 became unconditional return 22.0 (function now returns 22.0 even when no state bit is set, instead of none)
  • CheckAttackLockif local2 and local3: guard was dropped, causing GetBlackboardValueFromObject to be called with a potentially null vehicle reference

Fix: Always emit ret 0 at the end of every function, matching the Avalanche compiler behavior. One line changed in CodeGenerator.cs.