]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Make sure safe_memory is inside of any test memory regions.
authorToni Wilen <twilen@winuae.net>
Mon, 27 Jan 2020 18:32:05 +0000 (20:32 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 27 Jan 2020 18:32:05 +0000 (20:32 +0200)
cputest.cpp

index 148b096970c9331272dc61eb5412d1b0e3315948..6bd63b37ede3e7bab60acdc2833e4cfa4cb0b4c0 100644 (file)
@@ -4542,6 +4542,17 @@ static void my_trim(TCHAR *s)
                s[--len] = '\0';
 }
 
+static int check_safe_memory(uae_u32 start, uae_u32 end)
+{
+       if (start == 0xffffffff)
+               return 0;
+       if (safe_memory_start < start)
+               return 1;
+       if (safe_memory_end > end)
+               return 1;
+       return 0;
+}
+
 static const TCHAR *addrmodes[] =
 {
        _T("Dreg"), _T("Areg"), _T("Aind"), _T("Aipi"), _T("Apdi"), _T("Ad16"), _T("Ad8r"),
@@ -4877,6 +4888,16 @@ static int test(struct ini_data *ini, const TCHAR *sections, const TCHAR *testna
                high_memory_size = 0xffffffff;
        }
 
+       if (safe_memory_start != 0xffffffff) {
+               int err = check_safe_memory(test_low_memory_start, test_low_memory_end);
+               err += check_safe_memory(test_low_memory_start, test_low_memory_end);
+               err += check_safe_memory(test_high_memory_start, test_high_memory_end);
+               if (err == 3) {
+                       wprintf(_T("Safe_memory outside of all test memory regions!\n"));
+                       return 0;
+               }
+       }
+
        test_memory = (uae_u8 *)calloc(1, test_memory_size + EXTRA_RESERVED_SPACE);
        test_memory_temp = (uae_u8 *)calloc(1, test_memory_size);
        if (!test_memory || !test_memory_temp) {