From 823ee09e94ae0326eec91b6fdc18af5ae3823bd9 Mon Sep 17 00:00:00 2001 From: niansa Date: Wed, 10 Feb 2021 20:10:03 +0100 Subject: [PATCH] Fixed crash in evaluator --- pilang.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pilang.cpp b/pilang.cpp index ee6894f..7be8da1 100644 --- a/pilang.cpp +++ b/pilang.cpp @@ -37,7 +37,7 @@ namespace Pilang3 { bool newarg = false; bool escapenext = false; std::string cache; - for (auto characterit = expression.begin() + tspaces; characterit != expression.end(); characterit++) { + for (auto characterit = expression.begin() + tspaces; characterit < expression.end(); characterit++) { char character = *characterit; // Start new command name if (in_command_name) { @@ -160,6 +160,9 @@ namespace Pilang3 { thisfunc->evalChain.push_back(evaluation); // Skip over expression in iteration character = *(characterit += evaluation->exprlen + 1); + if (characterit == expression.end()) { + throw exceptions::UnexpectedEndOfExpression(); + } } character = *(++characterit); thisarg.data = thisfunc;