From 9e98097aae7216119055d117d44b976df1ff57ee Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 31 May 2017 21:43:41 +0200 Subject: [PATCH] closes https://github.com/assimp/assimp/issues/1244: log error for overflow. --- code/ObjFileParser.cpp | 14 -------------- code/fast_atof.h | 13 ++++++++++--- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 1f333d9..5f95bb9 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -289,7 +289,6 @@ size_t ObjFileParser::getNumComponentsInDataDefinition() { const char* tmp( &m_DataIt[0] ); bool end_of_definition = false; while ( !end_of_definition ) { - //while( !IsLineEnd( *tmp ) ) { if ( isDataDefinitionEnd( tmp ) ) { tmp += 2; } else if ( IsLineEnd( *tmp ) ) { @@ -420,10 +419,6 @@ static const std::string DefaultObjName = "defaultobject"; // ------------------------------------------------------------------- // Get values for a new face instance void ObjFileParser::getFace( aiPrimitiveType type ) { - //copyNextLine(m_buffer, Buffersize); - //char *pPtr = m_DataIt; - //char *pPtr = m_buffer; - //char *pEnd = &pPtr[Buffersize]; m_DataIt = getNextToken( m_DataIt, m_DataItEnd ); if ( m_DataIt == m_DataItEnd || *m_DataIt == '\0' ) { return; @@ -595,15 +590,6 @@ void ObjFileParser::getMaterialDesc() { // Get a comment, values will be skipped void ObjFileParser::getComment() { m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); - -/* while (m_DataIt != m_DataItEnd) { - if ( '\n' == (*m_DataIt)) { - ++m_DataIt; - break; - } else { - ++m_DataIt; - } - }*/ } // ------------------------------------------------------------------- diff --git a/code/fast_atof.h b/code/fast_atof.h index 965ff07..be1e592 100644 --- a/code/fast_atof.h +++ b/code/fast_atof.h @@ -1,3 +1,5 @@ +#pragma once + // Copyright (C) 2002-2007 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine" and the "irrXML" project. // For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h @@ -22,6 +24,7 @@ #include #include "StringComparison.h" +#include #ifdef _MSC_VER @@ -192,7 +195,7 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* uint64_t value = 0; if ( *in < '0' || *in > '9' ) - throw std::invalid_argument(std::string("The string \"") + in + "\" cannot be converted into a value."); + throw std::invalid_argument(std::string("The string \"") + in + "\" cannot be converted into a value."); bool running = true; while ( running ) @@ -202,8 +205,12 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* const uint64_t new_value = ( value * 10 ) + ( *in - '0' ); - if (new_value < value) /* numeric overflow, we rely on you */ - throw std::overflow_error(std::string("Converting the string \"") + in + "\" into a value resulted in overflow."); + // numeric overflow, we rely on you + if ( new_value < value ) { + DefaultLogger::get()->warn( std::string( "Converting the string \"" ) + in + "\" into a value resulted in overflow." ); + return 0; + } + //throw std::overflow_error(); value = new_value; -- 2.7.4