From 777adffdea48af0fb4714c89b58b7f0ccabdaed3 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Thu, 24 Oct 2024 18:11:19 +0200 Subject: [PATCH] registry bound check --- src/Assembleur.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Assembleur.cpp b/src/Assembleur.cpp index 50bf1c5..b2637a0 100644 --- a/src/Assembleur.cpp +++ b/src/Assembleur.cpp @@ -106,7 +106,10 @@ std::uint32_t Assembleur::ParseIO(Instruction a_Instruction, std::uint32_t a_R1, static std::uint32_t ParseRegistry(const std::string& a_Str) { if (a_Str.at(0) != 'R') throw std::runtime_error("Registry " + a_Str + " not found !"); - return std::stoi(a_Str.substr(1)); + std::uint32_t registry = std::stoi(a_Str.substr(1)); + if (registry > 7) + throw std::runtime_error("You can only have up to 8 registries !"); + return registry; } static bool IsConstant(const std::string& a_Str) {