about summary refs log tree commit diff stats
path: root/010---vm.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-02-05 10:33:28 -0800
committerKartik Agaram <vc@akkartik.com>2020-02-05 14:57:52 -0800
commit9ee351f37fbf78aa408f60c0d2c7ec49e625f109 (patch)
treeed55ef4c9cfcbedefda64767164855b576748c75 /010---vm.cc
parentb9d666eff51659a62dab7b746e5ae40431127e9b (diff)
downloadmu-9ee351f37fbf78aa408f60c0d2c7ec49e625f109.tar.gz
5983 - fix an emulator bounds-check bug
It was possible for an instruction to write out of bounds of the memory
data structure. Most of the time this worked fine. However if the block
ever got resized and moved the out-of-bounds bytes no longer went along.
Diffstat (limited to '010---vm.cc')
-rw-r--r--010---vm.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/010---vm.cc b/010---vm.cc
index a0724760..472990a0 100644
--- a/010---vm.cc
+++ b/010---vm.cc
@@ -108,7 +108,7 @@ struct vma {
   uint8_t& data(uint32_t a) {
     assert(match(a));
     uint32_t result_index = a-start;
-    if (_data.size() <= result_index) {
+    if (_data.size() <= result_index+/*largest word size that can be accessed in one instruction*/sizeof(int)) {
       const int align = 0x1000;
       uint32_t result_size = result_index + 1;  // size needed for result_index to be valid
       uint32_t new_size = align_upwards(result_size, align);