mirror of
https://github.com/pantor/inja.git
synced 2026-08-03 22:32:16 +00:00
add check for too few arguments in operator parser
This commit is contained in:
@@ -143,7 +143,7 @@ public:
|
||||
Op operation;
|
||||
|
||||
std::string name;
|
||||
int number_args; // Should also be negative -> -1 for unknown number
|
||||
int number_args; // Can also be negative -> -1 for unknown number
|
||||
std::vector<std::shared_ptr<ExpressionNode>> arguments;
|
||||
CallbackFunction callback;
|
||||
|
||||
|
||||
@@ -76,6 +76,10 @@ class Parser {
|
||||
auto function = operator_stack.top();
|
||||
operator_stack.pop();
|
||||
|
||||
if (static_cast<int>(arguments.size()) < function->number_args) {
|
||||
throw_parser_error("too few arguments");
|
||||
}
|
||||
|
||||
for (int i = 0; i < function->number_args; ++i) {
|
||||
function->arguments.insert(function->arguments.begin(), arguments.back());
|
||||
arguments.pop_back();
|
||||
|
||||
Reference in New Issue
Block a user