Merge pull request #1464 from assimp/issue_1453

Obj: prepare test to reproduce crash on linux.
pull/1479/head^2
Kim Kulling 2017-10-10 19:51:20 +02:00 committed by GitHub
commit c3074a81ca
3 changed files with 18 additions and 11 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 );
}
// -------------------------------------------------------------------
// 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 ) {
ai_real x, y, z;
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 );
}
// -------------------------------------------------------------------
// Get values for a new 2D vector instance
void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
ai_real x, y;
copyNextWord(m_buffer, Buffersize);
@ -405,8 +401,6 @@ void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
static const std::string DefaultObjName = "defaultobject";
// -------------------------------------------------------------------
// Get values for a new face instance
void ObjFileParser::getFace( aiPrimitiveType type ) {
m_DataIt = getNextToken<DataArrayIt>( m_DataIt, m_DataItEnd );
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 );
}
// -------------------------------------------------------------------
// Get values for a new material description
void ObjFileParser::getMaterialDesc() {
// Get next data for material data
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);
va_end(args);
#ifdef ASSIMP_BUILD_DEBUG
ai_assert( false );
#endif
throw DeadlyImportError("Validation failed: " + std::string(szBuffer,iLen));
}
// ------------------------------------------------------------------------------------------------

View File

@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -263,3 +264,19 @@ TEST_F( utObjImportExport, issue809_vertex_color_Test ) {
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/test.obj" ) );
#endif // ASSIMP_BUILD_NO_EXPORT
}
TEST_F( utObjImportExport, issue1453_segfault ) {
static const std::string ObjModel =
"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 *scene = myimporter.ReadFileFromMemory( ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure );
EXPECT_EQ( nullptr, scene );
}