From 3275119d1db551488fcf407a578e8a7a82714a76 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Thu, 2 Mar 2017 16:12:20 +0200 Subject: [PATCH] TokenFunc::asStringRef: protect against null token. --- src/ifcparse/IfcParse.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index a43d9dc821..8c1f92a061 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -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()) {