about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-24 21:05:28 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-24 21:05:28 -0700
commit9b035724e7277c8761a999d6a6dafd06382b776f (patch)
tree1f16157f935e2ada0bf2ae3f9c1c70b922c6fbe3
parent5eb49929b0ccc3b1660e9d7d26ba5adec363fb68 (diff)
downloadmu-9b035724e7277c8761a999d6a6dafd06382b776f.tar.gz
1180 - finally dump that 'pc' reference
In the process we uncovered yet another out-of-bounds access, in the
implementation of 'reply'. Another sign from the gods that large-scope
pointers/references are a bad idea.
-rw-r--r--cpp/020run3
-rw-r--r--cpp/037call_reply3
2 files changed, 2 insertions, 4 deletions
diff --git a/cpp/020run b/cpp/020run
index 2f08b23c..2d5d6228 100644
--- a/cpp/020run
+++ b/cpp/020run
@@ -52,7 +52,6 @@ void run_current_routine()
   while (!Current_routine->completed())  // later layers will modify condition
   {
     // Running One Instruction.
-    size_t& pc = current_step_index();
     if (current_instruction().is_label) { ++current_step_index(); continue; }
     trace("run") << "instruction " << current_recipe_name() << '/' << current_step_index();
 //?     cout << "operation " << current_instruction().operation << '\n'; //? 3
@@ -69,7 +68,7 @@ void run_current_routine()
         cout << "not a primitive op: " << current_instruction().operation << '\n';
       }
     }
-    ++pc;
+    ++current_step_index();
   }
   Current_routine = NULL;
 }
diff --git a/cpp/037call_reply b/cpp/037call_reply
index d48a17de..9e62c1da 100644
--- a/cpp/037call_reply
+++ b/cpp/037call_reply
@@ -33,8 +33,7 @@ case REPLY: {
     trace("run") << "result " << i << " is " << to_string(callee_results[i]);
     write_memory(caller_instruction.products[i], callee_results[i]);
   }
-  ++current_step_index();  // caller
-  break;
+  break;  // instruction loop will increment caller's step_index
 }
 
 //: Products can include containers and exclusive containers, addresses and arrays.