summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <tstellar@gmail.com>2010-12-16 14:50:03 -0800
committerTom Stellard <tstellar@gmail.com>2010-12-16 14:50:03 -0800
commitb8d6cde69092ef0762a769a51da01891a8ba6dc3 (patch)
treef4b05247c3fac535cf97468a9e50a4a5b80236e3
parent962a4157f5492972a679fe6dbfaa0a7288304e9f (diff)
emulator: Make sure index is valid when looking up an output value
-rw-r--r--emulator.cpp6
-rw-r--r--emulator.h2
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();
}
diff --git a/emulator.h b/emulator.h
index 3f64ca4..f1a3437 100644
--- a/emulator.h
+++ b/emulator.h
@@ -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;