From cdfd4b9702ebf053d00321fe5b47ab8a35695866 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 8 Nov 2017 20:44:53 +0100 Subject: [PATCH] closes https://github.com/assimp/assimp/issues/1315: check in exporting against out-of-bounds-access . --- code/ObjExporter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index fffafa328..6dd68b8f5 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -258,7 +258,6 @@ void ObjExporter::WriteMaterialFile() } } -// ------------------------------------------------------------------------------------------------ void ObjExporter::WriteGeometryFile(bool noMtl) { WriteHeader(mOutput); if (!noMtl) @@ -280,8 +279,10 @@ void ObjExporter::WriteGeometryFile(bool noMtl) { mOutput << "# " << vp.size() << " vertex positions and colors" << endl; size_t colIdx = 0; for ( const aiVector3D& v : vp ) { - mOutput << "v " << v.x << " " << v.y << " " << v.z << " " << vc[ colIdx ].r << " " << vc[ colIdx ].g << " " << vc[ colIdx ].b << endl; - colIdx++; + if ( colIdx < vc.size() ) { + mOutput << "v " << v.x << " " << v.y << " " << v.z << " " << vc[ colIdx ].r << " " << vc[ colIdx ].g << " " << vc[ colIdx ].b << endl; + } + ++colIdx; } } mOutput << endl;