From 5576b31aa690d02aac9125ecf1c680076792cef5 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Fri, 22 Apr 2011 15:54:42 +0000 Subject: [PATCH] # MD5 loader: fail early for empty files git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@959 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/MD5Loader.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/MD5Loader.cpp b/code/MD5Loader.cpp index dc9380a10..7e7ba2c3b 100644 --- a/code/MD5Loader.cpp +++ b/code/MD5Loader.cpp @@ -173,6 +173,7 @@ void MD5Importer::LoadFileIntoMemory (IOStream* file) ai_assert(NULL != file); fileSize = (unsigned int)file->FileSize(); + ai_assert(fileSize); // allocate storage and copy the contents of the file to a memory buffer pScene = pScene; @@ -334,8 +335,8 @@ void MD5Importer::LoadMD5MeshFile () boost::scoped_ptr file( pIOHandler->Open( pFile, "rb")); // Check whether we can read from the file - if( file.get() == NULL) { - DefaultLogger::get()->warn("Failed to read MD5MESH file: " + pFile); + if( file.get() == NULL || !file->FileSize()) { + DefaultLogger::get()->warn("Failed to access MD5MESH file: " + pFile); return; } bHadMD5Mesh = true; @@ -550,7 +551,7 @@ void MD5Importer::LoadMD5AnimFile () boost::scoped_ptr file( pIOHandler->Open( pFile, "rb")); // Check whether we can read from the file - if( file.get() == NULL) { + if( !file.get() || !file->FileSize()) { DefaultLogger::get()->warn("Failed to read MD5ANIM file: " + pFile); return; } @@ -665,7 +666,7 @@ void MD5Importer::LoadMD5CameraFile () boost::scoped_ptr file( pIOHandler->Open( pFile, "rb")); // Check whether we can read from the file - if( file.get() == NULL) { + if( !file.get() || !file->FileSize()) { throw DeadlyImportError("Failed to read MD5CAMERA file: " + pFile); } bHadMD5Camera = true;