fix segmentation fault

This commit is contained in:
pantor
2020-08-04 23:19:55 +02:00
parent 94d1f76357
commit b141129bda
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -139,7 +139,7 @@ class Parser {
add_json_literal(tmpl.content.c_str());
}
// Operator
// Operator
} else if (tok.text == "and" || tok.text == "or" || tok.text == "in" || tok.text == "not") {
goto parse_operator;
@@ -268,12 +268,12 @@ class Parser {
} break;
case Token::Kind::RightParen: {
current_paren_level -= 1;
while (operator_stack.top()->operation != FunctionStorage::Operation::ParenLeft) {
while (!operator_stack.empty() && operator_stack.top()->operation != FunctionStorage::Operation::ParenLeft) {
current_expression_list->rpn_output.emplace_back(operator_stack.top());
operator_stack.pop();
}
if (operator_stack.top()->operation == FunctionStorage::Operation::ParenLeft) {
if (!operator_stack.empty() && operator_stack.top()->operation == FunctionStorage::Operation::ParenLeft) {
operator_stack.pop();
}
+3 -3
View File
@@ -2851,7 +2851,7 @@ class Parser {
add_json_literal(tmpl.content.c_str());
}
// Operator
// Operator
} else if (tok.text == "and" || tok.text == "or" || tok.text == "in" || tok.text == "not") {
goto parse_operator;
@@ -2980,12 +2980,12 @@ class Parser {
} break;
case Token::Kind::RightParen: {
current_paren_level -= 1;
while (operator_stack.top()->operation != FunctionStorage::Operation::ParenLeft) {
while (!operator_stack.empty() && operator_stack.top()->operation != FunctionStorage::Operation::ParenLeft) {
current_expression_list->rpn_output.emplace_back(operator_stack.top());
operator_stack.pop();
}
if (operator_stack.top()->operation == FunctionStorage::Operation::ParenLeft) {
if (!operator_stack.empty() && operator_stack.top()->operation == FunctionStorage::Operation::ParenLeft) {
operator_stack.pop();
}