From bd02aac18aee04c804aece969bb478dffafe52fa Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 22 Mar 2014 13:02:21 +0000 Subject: [PATCH] No longer accept and silently convert invalid REAL tokens to zero --- src/ifcparse/IfcParse.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 399cc47db9..d447cc65e5 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -345,7 +345,11 @@ bool TokenFunc::asBool(const Token& t) { } double TokenFunc::asFloat(const Token& t) { const std::string str = asString(t); - return (double) atof(str.c_str()); + const char* start = str.c_str(); + char* end; + double result = strtod(start,&end); + if ( start == end ) throw IfcException("Token is not a real"); + return result; } std::string TokenFunc::asString(const Token& t) { if ( isOperator(t,'$') ) return "";