TokenFunc::asStringRef: protect against null token.

This commit is contained in:
Stinkfist0
2017-03-02 16:12:20 +02:00
committed by Thomas Krijnen
parent 026b4853a2
commit 3275119d1d
+3
View File
@@ -559,6 +559,9 @@ double TokenFunc::asFloat(const Token& t) {
}
const std::string &TokenFunc::asStringRef(const Token& t) {
if (t.type == Token_NONE) {
throw IfcParse::IfcException("Null token encountered, premature end of file?");
}
std::string &str = t.lexer->GetTempString();
t.lexer->TokenString(t.startPos, str);
if ((isString(t) || isEnumeration(t) || isBinary(t)) && !str.empty()) {