diff options
author | Tom Stellard <tstellar@gmail.com> | 2010-12-16 14:50:03 -0800 |
---|---|---|
committer | Tom Stellard <tstellar@gmail.com> | 2010-12-16 14:50:03 -0800 |
commit | b8d6cde69092ef0762a769a51da01891a8ba6dc3 (patch) | |
tree | f4b05247c3fac535cf97468a9e50a4a5b80236e3 | |
parent | 962a4157f5492972a679fe6dbfaa0a7288304e9f (diff) |
emulator: Make sure index is valid when looking up an output value
-rw-r--r-- | emulator.cpp | 6 | ||||
-rw-r--r-- | emulator.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/emulator.cpp b/emulator.cpp index dfcf78e..46abe5f 100644 --- a/emulator.cpp +++ b/emulator.cpp @@ -93,8 +93,10 @@ emulator::set_value( } value * -emulator::get_output_value(int index) +emulator::get_output_value(unsigned int index) { - //XXX: Make sure not to go over bounds. + if (index >= m_out_regs.size()) { + return NULL; + } return m_out_regs[index]->simplify(); } @@ -23,7 +23,7 @@ public: void set_value( register_address addr, value * val); - value * get_output_value(int index); + value * get_output_value(unsigned int index); private: program_loader * m_loader; |