Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions miasm/core/asmblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,11 @@ def sanity_check(self):
for loc_key in self._nodes:
if loc_key not in self._loc_key_to_block:
raise RuntimeError("Not supported yet: every node must have a corresponding AsmBlock")

block = self.loc_key_to_block(loc_key)
if not block.lines and not isinstance(block, AsmBlockBad):
raise RuntimeError("Blocks cannot be empty")

# No next constraint to self
if (loc_key, loc_key) in next_edges:
raise RuntimeError('Bad constraint: self in next')
Expand Down
7 changes: 7 additions & 0 deletions test/core/asmblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ def remove_useless_blocks(d_g, graph):
assert len(list(asmcfg.get_bad_blocks_predecessors(strict=True))) == 0

## Sanity check
flag = False
try:
asmcfg.sanity_check()
except RuntimeError:
flag = True
assert flag
my_block.lines = [first_block.lines[0]]
asmcfg.sanity_check()
### Next on itself
testlabel_nextitself = mdis.loc_db.get_or_create_name_location("testlabel_nextitself")
Expand Down