Add check for mismatched rparen.

This commit is contained in:
Brian Taylor 2024-03-18 17:18:34 -07:00
parent 91e49ce4d6
commit fb245ec98c
1 changed files with 5 additions and 0 deletions

View File

@ -805,6 +805,11 @@ static int infix_to_postfix(char* infix, DSTRING * postfix_p)
}
} else if (ltok == ')') {
rparen_count++;
if (rparen_count > lparen_count) {
fprintf(stderr, "ERROR (9a) mismatched rparen\n");
status = 1;
goto err_return;
}
while ( stack.top != -1 && !eq(stack.array[stack.top], "(") ) {
ds_cat_printf(postfix_p, " %s", pop(&stack, &status));
if (status) {