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;