Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix memory access checks for accesses one past the end of the ROM.

  • Loading branch information...
commit b59ba9add47d25f5e21d673343bf9c1e2ad5d898 1 parent 7b025dd
@nelhage authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 MMU.js
View
4 MMU.js
@@ -5,14 +5,14 @@ var MMU = {
},
read: function(addr) {
var ea = (addr & ~CPU.PC_SUPERVISOR) >> 2;
- if (ea > MMU.memory.length) {
+ if (ea >= MMU.memory.length) {
throw new Error("Invalid read: " + (addr & ~CPU.PC_SUPERVISOR));
}
return MMU.memory[ea];
},
write: function(addr, data) {
var ea = (addr & ~CPU.PC_SUPERVISOR) >> 2;
- if (ea > MMU.memory.length) {
+ if (ea >= MMU.memory.length) {
throw new Error("Invalid read: " + (addr & ~CPU.PC_SUPERVISOR));
}
MMU.memory[ea] = data;
Please sign in to comment.
Something went wrong with that request. Please try again.