diff -uNrp src/src/core/indexing.cpp src.new/src/core/indexing.cpp --- src/src/core/indexing.cpp 2013-04-01 13:01:20 +0300 +++ src.new/src/core/indexing.cpp 2013-08-28 12:38:17 +0300 @@ -542,6 +542,15 @@ void FFMS_Index::WriteIndex(const char * void FFMS_Index::ReadIndex(const char *IndexFile) { ffms_fstream Index(IndexFile, std::ios::in | std::ios::binary); + std::streampos fsize = Index.tellg(); + Index.seekg( 0, std::ios::end ); + fsize = Index.tellg() - fsize; + Index.seekg( 0, std::ios::beg ); + + if (fsize == 0) + throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_FILE_READ, + std::string("'") + IndexFile + "' is not a valid index file"); + if (!Index.is_open()) throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_FILE_READ, std::string("Failed to open '") + IndexFile + "' for reading");