From ec8007125f109359a362f7cd927a62836caf8b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 21 Jun 2017 16:48:43 +0200 Subject: [PATCH] Fixed segfault occurring with accidentally unnamed variables. --- .../src/pddlparse/detail/parsing/VariableDeclaration.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pddlparse/src/pddlparse/detail/parsing/VariableDeclaration.cpp b/lib/pddlparse/src/pddlparse/detail/parsing/VariableDeclaration.cpp index 76b8ab3..eaf44c6 100644 --- a/lib/pddlparse/src/pddlparse/detail/parsing/VariableDeclaration.cpp +++ b/lib/pddlparse/src/pddlparse/detail/parsing/VariableDeclaration.cpp @@ -21,8 +21,15 @@ void parseAndAddUntypedVariableDeclaration(Context &context, ast::VariableDeclar auto &tokenizer = context.tokenizer; tokenizer.expect("?"); + const auto position = tokenizer.position(); + auto variableName = tokenizer.getIdentifier(); - assert(variableName != "-"); + + if (variableName == "" || variableName == "-") + { + tokenizer.seek(position); + throw ParserException(tokenizer.location(), "could not parse variable name"); + } variableDeclarations.emplace_back(std::make_unique(std::move(variableName))); }