From 3a31f9f79f7f21e67ddb5eeee362f8f21b5d77ef Mon Sep 17 00:00:00 2001 From: m8pple Date: Mon, 24 Oct 2016 19:41:41 +0100 Subject: Allow 512MB ram at request of @lorenzo2897. Closes #42. --- src/shared/mips_mem_ram.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/mips_mem_ram.cpp b/src/shared/mips_mem_ram.cpp index 0a01b5b..3d4d6d2 100644 --- a/src/shared/mips_mem_ram.cpp +++ b/src/shared/mips_mem_ram.cpp @@ -18,7 +18,7 @@ struct mips_mem_provider extern "C" mips_mem_h mips_mem_create_ram( uint32_t cbMem //!< Total number of bytes of ram ){ - if(cbMem>0x10000000){ + if(cbMem>0x20000000){ return 0; // No more than 256MB of RAM } -- cgit From fead3ef10057760c977503b3b564048cbfc76ce5 Mon Sep 17 00:00:00 2001 From: George Punter Date: Tue, 25 Oct 2016 09:33:49 +0100 Subject: Fixed subtle bug and changed comment about max RAM size --- src/shared/mips_mem_ram.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/mips_mem_ram.cpp b/src/shared/mips_mem_ram.cpp index 3d4d6d2..81ae63f 100644 --- a/src/shared/mips_mem_ram.cpp +++ b/src/shared/mips_mem_ram.cpp @@ -19,7 +19,7 @@ extern "C" mips_mem_h mips_mem_create_ram( uint32_t cbMem //!< Total number of bytes of ram ){ if(cbMem>0x20000000){ - return 0; // No more than 256MB of RAM + return 0; // No more than 512MB of RAM } uint8_t *data=(uint8_t*)malloc(cbMem); @@ -57,7 +57,7 @@ static mips_error mips_mem_read_write( if(0 != (address % length) ){ return mips_ExceptionInvalidAlignment; } - if((address+length) > mem->length){ // A subtle bug here, maybe? + if((address+length) > mem->length || address > (UINT32_MAX - length)){ // A subtle bug here, maybe? return mips_ExceptionInvalidAddress; } -- cgit From 081d37380546cb269f724c008bd34897c5a237df Mon Sep 17 00:00:00 2001 From: George Punter Date: Tue, 25 Oct 2016 09:35:29 +0100 Subject: Added brackets for peace of mind --- src/shared/mips_mem_ram.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/mips_mem_ram.cpp b/src/shared/mips_mem_ram.cpp index 81ae63f..179c8fd 100644 --- a/src/shared/mips_mem_ram.cpp +++ b/src/shared/mips_mem_ram.cpp @@ -57,7 +57,7 @@ static mips_error mips_mem_read_write( if(0 != (address % length) ){ return mips_ExceptionInvalidAlignment; } - if((address+length) > mem->length || address > (UINT32_MAX - length)){ // A subtle bug here, maybe? + if(((address+length) > mem->length) || (address > (UINT32_MAX - length))){ // A subtle bug here, maybe? return mips_ExceptionInvalidAddress; } -- cgit