From c34a548fa0ab39f034d4cd2f399fe21ec68dba2d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 24 Jun 2021 22:19:50 -0400 Subject: [PATCH] Ensure character pixel reads can't go out of bounds. --- Machines/Enterprise/Nick.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Machines/Enterprise/Nick.cpp b/Machines/Enterprise/Nick.cpp index 933376a73..be9bfd0c1 100644 --- a/Machines/Enterprise/Nick.cpp +++ b/Machines/Enterprise/Nick.cpp @@ -562,10 +562,10 @@ template void Nick::output_character(uint16_t *target, const uint8_t character = ram_[line_data_pointer_[0]]; ++line_data_pointer_[0]; - const uint8_t pixels = ram_[ + const uint8_t pixels = ram_[( (line_data_pointer_[1] << index_bits) + (character & ((1 << index_bits) - 1)) - ]; + ) & 0xffff]; // TODO: below looks repetitious of the above, but I've yet to factor in // ALTINDs and [M/L]SBALTs, so I'll correct for factoring when I've done that.