diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp index 6179fc3da5..f90b1ded71 100644 --- a/src/core/indexing.cpp +++ b/src/core/indexing.cpp @@ -180,7 +180,6 @@ void FFMS_Index::WriteIndex(const char *IndexFile) { FFMS_Index::FFMS_Index(const char *IndexFile) : RefCount(1) { - // todo: check if crashes on empty index file ZipFile zf(IndexFile, "rb"); // Read the index file header diff --git a/src/core/zipfile.cpp b/src/core/zipfile.cpp index 8f6bed018f..0bd5f5669a 100644 --- a/src/core/zipfile.cpp +++ b/src/core/zipfile.cpp @@ -56,6 +56,8 @@ void ZipFile::Read(void *data, size_t size) { z.next_in = reinterpret_cast(&buffer[0]); z.avail_in = file.Read(&buffer[0], buffer.size()); } + if (!z.avail_in && !file.Tell()) + throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_FILE_READ, "Failed to read data: File is empty"); switch (inflate(&z, Z_SYNC_FLUSH)) { case Z_NEED_DICT: