Index: courgette/disassembler.h |
diff --git a/courgette/disassembler.h b/courgette/disassembler.h |
index 77abd41966e5ddf032538a1e64854fa1c5bf073e..0154ec4bab1d5a6f9652c9989e5d5ab407458d48 100644 |
--- a/courgette/disassembler.h |
+++ b/courgette/disassembler.h |
@@ -54,6 +54,11 @@ class Disassembler { |
bool Good(); |
bool Bad(const char *reason); |
+ // Returns true if the array lies within our memory region. |
+ bool IsArrayInBounds(size_t offset, size_t elements, size_t element_size) { |
+ return offset <= length() && elements <= (length() - offset) / element_size; |
+ } |
+ |
// These helper functions avoid the need for casts in the main code. |
uint16 ReadU16(const uint8* address, size_t offset) { |
return *reinterpret_cast<const uint16*>(address + offset); |