Avoid segfault if parser `ref' is empty

This commit is contained in:
Andrew Hutchings
2015-11-17 11:11:03 -03:00
committed by Felipe Zimmerle
parent f65b08b066
commit c035e76ede
3 changed files with 5 additions and 11 deletions

View File

@@ -167,7 +167,9 @@ void Driver::error(const yy::location& l, const std::string& m,
const std::string& c) {
if (parserError.tellp() == 0) {
parserError << "Rules error. ";
parserError << "File: " << ref.back() << ". ";
if (ref.empty() == false) {
parserError << "File: " << ref.back() << ". ";
}
parserError << "Line: " << l.end.line << ". ";
parserError << "Column: " << l.end.column << ". ";
}