From e13f6876bb34a6dd2d6b42680e7b0123bd53e07f Mon Sep 17 00:00:00 2001 From: kimkulling Date: Wed, 11 Jul 2018 10:10:26 +0200 Subject: [PATCH] closes https://github.com/assimp/assimp/issues/1340: Fix handling of empty nodes in openddl-parser. --- contrib/openddlparser/code/OpenDDLParser.cpp | 6 ++++++ test/unit/utOpenGEXImportExport.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/contrib/openddlparser/code/OpenDDLParser.cpp b/contrib/openddlparser/code/OpenDDLParser.cpp index caa281364..91831ba27 100644 --- a/contrib/openddlparser/code/OpenDDLParser.cpp +++ b/contrib/openddlparser/code/OpenDDLParser.cpp @@ -100,9 +100,15 @@ static bool isUnsignedIntegerType( Value::ValueType integerType ) { } static DDLNode *createDDLNode( Text *id, OpenDDLParser *parser ) { + // Basic checks if( ddl_nullptr == id || ddl_nullptr == parser ) { return ddl_nullptr; } + + // If the buffer is empty ( an empty node ) return nullptr + if ( ddl_nullptr == id->m_buffer ) { + return ddl_nullptr; + } const std::string type( id->m_buffer ); DDLNode *parent( parser->top() ); diff --git a/test/unit/utOpenGEXImportExport.cpp b/test/unit/utOpenGEXImportExport.cpp index 9a860f514..313a7210e 100644 --- a/test/unit/utOpenGEXImportExport.cpp +++ b/test/unit/utOpenGEXImportExport.cpp @@ -68,3 +68,9 @@ TEST_F( utOpenGEXImportExport, Importissue1262_NoCrash ) { EXPECT_NE( nullptr, scene ); } + +TEST_F(utOpenGEXImportExport, Importissue1340_EmptyCameraObject) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OpenGEX/empty_camera.ogex", 0); + EXPECT_NE(nullptr, scene); +}