aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm8pple <dt10@imperial.ac.uk>2016-10-26 17:18:55 +0100
committerGitHub <noreply@github.com>2016-10-26 17:18:55 +0100
commita063f91a1b1d09a6eb41cc025810f72b2b2df948 (patch)
tree1090f72995f235e3d1b3668197a7581ef911c37e
parent3a31f9f79f7f21e67ddb5eeee362f8f21b5d77ef (diff)
parent081d37380546cb269f724c008bd34897c5a237df (diff)
downloadMipsCPU-a063f91a1b1d09a6eb41cc025810f72b2b2df948.tar.gz
MipsCPU-a063f91a1b1d09a6eb41cc025810f72b2b2df948.zip
Merge pull request #44 from ps-george/master
Fix for subtle bug
-rw-r--r--src/shared/mips_mem_ram.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shared/mips_mem_ram.cpp b/src/shared/mips_mem_ram.cpp
index 3d4d6d2..179c8fd 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;
}