Reproduce issue and remove assertion when a nullptr makes more sence

pull/1464/head
Kim Kulling 2017-10-07 19:08:20 +02:00
parent 2056e56bdb
commit f925e2cf4e
3 changed files with 13 additions and 20 deletions

View File

@ -359,8 +359,6 @@ void ObjFileParser::getHomogeneousVector3( std::vector<aiVector3D> &point3d_arra
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine ); m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
} }
// -------------------------------------------------------------------
// Get values for two 3D vectors on the same line
void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, std::vector<aiVector3D> &point3d_array_b ) { void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, std::vector<aiVector3D> &point3d_array_b ) {
ai_real x, y, z; ai_real x, y, z;
copyNextWord(m_buffer, Buffersize); copyNextWord(m_buffer, Buffersize);
@ -388,8 +386,6 @@ void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, st
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine ); m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
} }
// -------------------------------------------------------------------
// Get values for a new 2D vector instance
void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) { void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
ai_real x, y; ai_real x, y;
copyNextWord(m_buffer, Buffersize); copyNextWord(m_buffer, Buffersize);
@ -405,8 +401,6 @@ void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
static const std::string DefaultObjName = "defaultobject"; static const std::string DefaultObjName = "defaultobject";
// -------------------------------------------------------------------
// Get values for a new face instance
void ObjFileParser::getFace( aiPrimitiveType type ) { void ObjFileParser::getFace( aiPrimitiveType type ) {
m_DataIt = getNextToken<DataArrayIt>( m_DataIt, m_DataItEnd ); m_DataIt = getNextToken<DataArrayIt>( m_DataIt, m_DataItEnd );
if ( m_DataIt == m_DataItEnd || *m_DataIt == '\0' ) { if ( m_DataIt == m_DataItEnd || *m_DataIt == '\0' ) {
@ -522,8 +516,6 @@ void ObjFileParser::getFace( aiPrimitiveType type ) {
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine ); m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
} }
// -------------------------------------------------------------------
// Get values for a new material description
void ObjFileParser::getMaterialDesc() { void ObjFileParser::getMaterialDesc() {
// Get next data for material data // Get next data for material data
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd); m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);

View File

@ -89,9 +89,7 @@ AI_WONT_RETURN void ValidateDSProcess::ReportError(const char* msg,...)
ai_assert(iLen > 0); ai_assert(iLen > 0);
va_end(args); va_end(args);
#ifdef ASSIMP_BUILD_DEBUG
ai_assert( false );
#endif
throw DeadlyImportError("Validation failed: " + std::string(szBuffer,iLen)); throw DeadlyImportError("Validation failed: " + std::string(szBuffer,iLen));
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -46,6 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp> #include <assimp/Exporter.hpp>
#include <assimp/postprocess.h>
#include <code/Exceptional.h>
using namespace Assimp; using namespace Assimp;
@ -257,15 +259,16 @@ TEST_F( utObjImportExport, issue809_vertex_color_Test ) {
TEST_F( utObjImportExport, issue1453_segfault ) { TEST_F( utObjImportExport, issue1453_segfault ) {
static const std::string ObjModel = static const std::string ObjModel =
"v 0.0 0.0 0.0" "v 0.0 0.0 0.0\n"
"v 0.0 0.0 1.0" "v 0.0 0.0 1.0\n"
"v 0.0 1.0 0.0" "v 0.0 1.0 0.0\n"
"v 0.0 1.0 1.0" "v 0.0 1.0 1.0\n"
"v 1.0 0.0 0.0" "v 1.0 0.0 0.0\n"
"v 1.0 0.0 1.0" "v 1.0 0.0 1.0\n"
"v 1.0 1.0 0.0" "v 1.0 1.0 0.0\n"
"v 1.0 1.0 1.0"; "v 1.0 1.0 1.0\nB";
Assimp::Importer myimporter; 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 );
} }