From f925e2cf4e37cf8923bc2348e2c665379675a90e Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 7 Oct 2017 19:08:20 +0200 Subject: [PATCH] Reproduce issue and remove assertion when a nullptr makes more sence --- code/ObjFileParser.cpp | 8 -------- code/ValidateDataStructure.cpp | 4 +--- test/unit/utObjImportExport.cpp | 21 ++++++++++++--------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 41677fce5..acf275b94 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -359,8 +359,6 @@ void ObjFileParser::getHomogeneousVector3( std::vector &point3d_arra m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } -// ------------------------------------------------------------------- -// Get values for two 3D vectors on the same line void ObjFileParser::getTwoVectors3( std::vector &point3d_array_a, std::vector &point3d_array_b ) { ai_real x, y, z; copyNextWord(m_buffer, Buffersize); @@ -388,8 +386,6 @@ void ObjFileParser::getTwoVectors3( std::vector &point3d_array_a, st m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } -// ------------------------------------------------------------------- -// Get values for a new 2D vector instance void ObjFileParser::getVector2( std::vector &point2d_array ) { ai_real x, y; copyNextWord(m_buffer, Buffersize); @@ -405,8 +401,6 @@ void ObjFileParser::getVector2( std::vector &point2d_array ) { static const std::string DefaultObjName = "defaultobject"; -// ------------------------------------------------------------------- -// Get values for a new face instance void ObjFileParser::getFace( aiPrimitiveType type ) { m_DataIt = getNextToken( m_DataIt, m_DataItEnd ); if ( m_DataIt == m_DataItEnd || *m_DataIt == '\0' ) { @@ -522,8 +516,6 @@ void ObjFileParser::getFace( aiPrimitiveType type ) { m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } -// ------------------------------------------------------------------- -// Get values for a new material description void ObjFileParser::getMaterialDesc() { // Get next data for material data m_DataIt = getNextToken(m_DataIt, m_DataItEnd); diff --git a/code/ValidateDataStructure.cpp b/code/ValidateDataStructure.cpp index ae1e0d342..f1035e441 100644 --- a/code/ValidateDataStructure.cpp +++ b/code/ValidateDataStructure.cpp @@ -89,9 +89,7 @@ AI_WONT_RETURN void ValidateDSProcess::ReportError(const char* msg,...) ai_assert(iLen > 0); va_end(args); -#ifdef ASSIMP_BUILD_DEBUG - ai_assert( false ); -#endif + throw DeadlyImportError("Validation failed: " + std::string(szBuffer,iLen)); } // ------------------------------------------------------------------------------------------------ diff --git a/test/unit/utObjImportExport.cpp b/test/unit/utObjImportExport.cpp index 94bc71f67..59fd58a6f 100644 --- a/test/unit/utObjImportExport.cpp +++ b/test/unit/utObjImportExport.cpp @@ -46,6 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include +#include using namespace Assimp; @@ -257,15 +259,16 @@ TEST_F( utObjImportExport, issue809_vertex_color_Test ) { TEST_F( utObjImportExport, issue1453_segfault ) { static const std::string ObjModel = - "v 0.0 0.0 0.0" - "v 0.0 0.0 1.0" - "v 0.0 1.0 0.0" - "v 0.0 1.0 1.0" - "v 1.0 0.0 0.0" - "v 1.0 0.0 1.0" - "v 1.0 1.0 0.0" - "v 1.0 1.0 1.0"; + "v 0.0 0.0 0.0\n" + "v 0.0 0.0 1.0\n" + "v 0.0 1.0 0.0\n" + "v 0.0 1.0 1.0\n" + "v 1.0 0.0 0.0\n" + "v 1.0 0.0 1.0\n" + "v 1.0 1.0 0.0\n" + "v 1.0 1.0 1.0\nB"; Assimp::Importer myimporter; - const aiScene* myscene = myimporter.ReadFileFromMemory( ObjModel.c_str(), ObjModel.size(), 0 ); + const aiScene *scene = myimporter.ReadFileFromMemory( ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure ); + EXPECT_EQ( nullptr, scene ); }