]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Halt if initial PC is corrupt or odd.
authorToni Wilen <twilen@winuae.net>
Sun, 16 Apr 2017 19:11:45 +0000 (22:11 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 16 Apr 2017 19:11:45 +0000 (22:11 +0300)
include/newcpu.h
newcpu.cpp

index 0c3ac3a9378e434eaece11b61b01234239bb3a5d..ebee8729958f7f629522c8925e489845dcd90694 100644 (file)
@@ -693,6 +693,7 @@ extern bool can_cpu_tracer (void);
 #define CPU_HALT_PCI_CONFLICT 8
 #define CPU_HALT_CPU_STUCK 9
 #define CPU_HALT_SSP_IN_NON_EXISTING_ADDRESS 10
+#define CPU_HALT_INVALID_START_ADDRESS 11
 
 void cpu_semaphore_get(void);
 void cpu_semaphore_release(void);
index b5e26d37ecfbc60d937f80dd49c0cc10b6ba8b5e..7a99c54663fce28e40242c30c4708c658629dacb 100644 (file)
@@ -5571,6 +5571,14 @@ void m68k_go (int may_quit)
                event_wait = true;
                unset_special(SPCFLAG_MODE_CHANGE);
 
+               if (!regs.halted) {
+                       // check that PC points to something that looks like memory.
+                       uaecptr pc = m68k_getpc();
+                       addrbank *ab = get_mem_bank_real(pc);
+                       if (ab == NULL || ab == &dummy_bank || (!currprefs.cpu_compatible && !valid_address(pc, 2)) || (pc & 1)) {
+                               cpu_halt(CPU_HALT_INVALID_START_ADDRESS);
+                       }
+               }
                if (regs.halted) {
                        cpu_halt (regs.halted);
                        if (regs.halted < 0) {