closes https://github.com/assimp/assimp/issues/1315: check in exporting against out-of-bounds-access .

pull/1555/head
Kim Kulling 2017-11-08 20:44:53 +01:00
parent a88a23ac7c
commit cdfd4b9702
1 changed files with 4 additions and 3 deletions

View File

@ -258,7 +258,6 @@ void ObjExporter::WriteMaterialFile()
} }
} }
// ------------------------------------------------------------------------------------------------
void ObjExporter::WriteGeometryFile(bool noMtl) { void ObjExporter::WriteGeometryFile(bool noMtl) {
WriteHeader(mOutput); WriteHeader(mOutput);
if (!noMtl) if (!noMtl)
@ -280,8 +279,10 @@ void ObjExporter::WriteGeometryFile(bool noMtl) {
mOutput << "# " << vp.size() << " vertex positions and colors" << endl; mOutput << "# " << vp.size() << " vertex positions and colors" << endl;
size_t colIdx = 0; size_t colIdx = 0;
for ( const aiVector3D& v : vp ) { for ( const aiVector3D& v : vp ) {
mOutput << "v " << v.x << " " << v.y << " " << v.z << " " << vc[ colIdx ].r << " " << vc[ colIdx ].g << " " << vc[ colIdx ].b << endl; if ( colIdx < vc.size() ) {
colIdx++; mOutput << "v " << v.x << " " << v.y << " " << v.z << " " << vc[ colIdx ].r << " " << vc[ colIdx ].g << " " << vc[ colIdx ].b << endl;
}
++colIdx;
} }
} }
mOutput << endl; mOutput << endl;