Throw when trying to read past the end of SMTLib stream

This commit is contained in:
Martin Blicha
2023-09-05 12:39:19 +02:00
parent d3bbc51ee9
commit 8e0e2cb1ae
3 changed files with 26 additions and 6 deletions
+22 -6
View File
@@ -675,10 +675,19 @@ CHCSolverInterface::CexGraph CHCSmtLib2Interface::graphFromZ3Proof(std::string c
if (parser.isEOF()) // No proof from Z3
return {};
// For some reason Z3 outputs everything as a single s-expression
auto all = parser.parseExpression();
SMTLib2Expression parsedOutput;
try
{
parsedOutput = parser.parseExpression();
}
catch (SMTLib2Parser::ParsingException&)
{
// TODO: What should we do in this case?
smtAssert(false, "SMTLIb2Parser: Error parsing input");
}
solAssert(parser.isEOF());
solAssert(!isAtom(all));
auto& commands = std::get<SMTLib2Expression::args_t>(all.data);
solAssert(!isAtom(parsedOutput));
auto& commands = asSubExpressions(parsedOutput);
SMTLibTranslationContext context(*m_smtlib2);
for (auto& command: commands)
{
@@ -720,10 +729,17 @@ smtutil::Expression CHCSmtLib2Interface::invariantsFromSMTLib(std::string const&
if (parser.isEOF()) // No model
return Expression(true);
// For some reason Z3 outputs everything as a single s-expression
auto all = parser.parseExpression();
SMTLib2Expression parsedOutput;
try {
parsedOutput = parser.parseExpression();
} catch(SMTLib2Parser::ParsingException&)
{
// TODO: What should we do in this case?
smtAssert(false, "SMTLIb2Parser: Error parsing input");
}
solAssert(parser.isEOF());
solAssert(!isAtom(all));
auto& commands = std::get<SMTLib2Expression::args_t>(all.data);
solAssert(!isAtom(parsedOutput));
auto& commands = asSubExpressions(parsedOutput);
std::vector<Expression> definitions;
for (auto& command: commands)
{