diff options
| author | Ficture Seven <FICTURE7@gmail.com> | 2020-07-15 11:48:16 +0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-15 17:48:16 +1000 |
| commit | 863b0c8dcbf3a4fdf07eb43148e0f7d100947551 (patch) | |
| tree | 9adf3a4bc1a38a4a057f729d82b278473fe59683 | |
| parent | 788ca6a411762035a6a7a88100c4b582b47ee82d (diff) | |
Fix Decode exception condition (#1377)
| -rw-r--r-- | ARMeilleure/Decoders/Decoder.cs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ARMeilleure/Decoders/Decoder.cs b/ARMeilleure/Decoders/Decoder.cs index de62d125..9ec95ab6 100644 --- a/ARMeilleure/Decoders/Decoder.cs +++ b/ARMeilleure/Decoders/Decoder.cs @@ -4,6 +4,7 @@ using ARMeilleure.Memory; using ARMeilleure.State; using System; using System.Collections.Generic; +using System.Diagnostics; namespace ARMeilleure.Decoders { @@ -132,17 +133,22 @@ namespace ARMeilleure.Decoders } } - if (blocks.Count == 0) + if (blocks.Count == 1 && blocks[0].OpCodes.Count == 0) { - throw new InvalidOperationException($"Decoded 0 blocks. Entry point = 0x{address:X}."); + Debug.Assert(blocks[0].Exit); + Debug.Assert(blocks[0].Address == blocks[0].EndAddress); + + throw new InvalidOperationException($"Decoded a single empty exit block. Entry point = 0x{address:X}."); } if (!singleBlock) { return TailCallRemover.RunPass(address, blocks); } - - return blocks.ToArray(); + else + { + return blocks.ToArray(); + } } public static bool BinarySearch(List<Block> blocks, ulong address, out int index) |
