Skip to content

Show Condition As Inverted sometimes results in incorrect decompiled code #7175

@comex

Description

@comex

Version and Platform (required):

  • Binary Ninja Version: 5.1.8002-dev (9b330043)
  • Edition: Commercial
  • OS: macOS
  • OS Version: 15.5 (24F74)
  • CPU Architecture: ARM

Bug Description:

Possibly related to #7080, but the effect here is worse. See also #7176.

Here is the reproducer. For this report we're looking at func2 (func1 is for another report).

The initial decompilation I get is:

0040001c    void func2(int64_t arg1, int64_t arg2)
0040001c        if (arg2 == 0)
0040001c            return 
0040001c        
00400030        if (*extern1() == 0)
0040003c            extern3()
00400040            return 
00400040        
00400034        extern2()

If I right-click on the line for 00400030 and click Show Condition As Inverted, it inverts the condition (the == turns into !=), but nothing else changes - the code blocks don't move. So now it says this, which is wrong:

0040001c    void func2(int64_t arg1, int64_t arg2)
0040001c        if (arg2 == 0)
0040001c            return 
0040001c        
00400030        if (*extern1() != 0)
0040003c            extern3()
00400040            return 
00400040        
00400034        extern2()

Metadata

Metadata

Assignees

Labels

Component: CoreIssue needs changes to the coreCore: HLILIssue involves High Level ILEffort: LowIssue should take < 1 weekImpact: MediumIssue is impactful with a bad, or no, workaround

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions