From 16f9ca35d2ee5e6817bae367e7fb264d0884532b Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 26 Jan 2015 15:05:18 +0200 Subject: [PATCH] Fix out-of-bounds read when OFF file contains no vertices --- code/OFFLoader.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/OFFLoader.cpp b/code/OFFLoader.cpp index 23a1815c3..ca440a458 100644 --- a/code/OFFLoader.cpp +++ b/code/OFFLoader.cpp @@ -127,6 +127,13 @@ void OFFImporter::InternReadFile( const std::string& pFile, const unsigned int numVertices = strtoul10(sz,&sz);SkipSpaces(&sz); const unsigned int numFaces = strtoul10(sz,&sz); + if (!numVertices) { + throw DeadlyImportError("OFF: There are no valid vertices"); + } + if (!numFaces) { + throw DeadlyImportError("OFF: There are no valid faces"); + } + pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes = 1 ]; aiMesh* mesh = pScene->mMeshes[0] = new aiMesh(); aiFace* faces = mesh->mFaces = new aiFace [mesh->mNumFaces = numFaces];