mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
TokenFunc::asStringRef: protect against null token.
This commit is contained in:
committed by
Thomas Krijnen
parent
026b4853a2
commit
3275119d1d
@@ -559,6 +559,9 @@ double TokenFunc::asFloat(const Token& t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::string &TokenFunc::asStringRef(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();
|
std::string &str = t.lexer->GetTempString();
|
||||||
t.lexer->TokenString(t.startPos, str);
|
t.lexer->TokenString(t.startPos, str);
|
||||||
if ((isString(t) || isEnumeration(t) || isBinary(t)) && !str.empty()) {
|
if ((isString(t) || isEnumeration(t) || isBinary(t)) && !str.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user