From 617c5700ca520d80fd25fc0fc9f2389394a46150 Mon Sep 17 00:00:00 2001
From: Somebody Whoisbored <13044396+shadowninja108@users.noreply.github.com>
Date: Sun, 5 Nov 2023 04:32:17 -0700
Subject: Better handle instruction aborts when hitting unmapped memory (#5869)

* Adjust ARMeilleure to better handle instruction aborts when hitting unmapped memory

* Update src/ARMeilleure/Decoders/Decoder.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

---------

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
---
 src/ARMeilleure/Decoders/Decoder.cs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/ARMeilleure/Decoders/Decoder.cs b/src/ARMeilleure/Decoders/Decoder.cs
index 6d07827a..66d28692 100644
--- a/src/ARMeilleure/Decoders/Decoder.cs
+++ b/src/ARMeilleure/Decoders/Decoder.cs
@@ -38,7 +38,9 @@ namespace ARMeilleure.Decoders
                 {
                     block = new Block(blkAddress);
 
-                    if ((dMode != DecoderMode.MultipleBlocks && visited.Count >= 1) || opsCount > instructionLimit || !memory.IsMapped(blkAddress))
+                    if ((dMode != DecoderMode.MultipleBlocks && visited.Count >= 1) ||
+                        opsCount > instructionLimit ||
+                        (visited.Count > 0 && !memory.IsMapped(blkAddress)))
                     {
                         block.Exit = true;
                         block.EndAddress = blkAddress;
-- 
cgit v1.2.3-70-g09d2