From 21bddbb0d99e4756945d57f4e5f06e55be5d977a Mon Sep 17 00:00:00 2001 From: Denis Chernikov Date: Wed, 9 Oct 2019 18:30:07 +0300 Subject: [PATCH] Possible infinite recursion of empty parentheses #1 --- PrimaryExp.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PrimaryExp.java b/PrimaryExp.java index fb51837..4ebe342 100644 --- a/PrimaryExp.java +++ b/PrimaryExp.java @@ -43,6 +43,9 @@ static AstNode parsePrimary(ExpParser parser, boolean isInsideParenthesis) throw if (parser.isEnd()) { // Opening parenthesis can't stay at the end of the string throw new ExpressionFormatException("Wrong opening parenthesis detected"); } + else if (parser.getLast().equals(OPCODES[1])) { // If next is ")" - exception + throw new ExpressionFormatException("Empty parentheses detected"); + } // Parse subexpression from the top operations res = LogicalExp.parseLogical(parser, true); if (!parser.getLast().equals(OPCODES[1])) { // If next is not ")" - exception