Skip to content

Commit

Permalink
Fix infinite loop on empty index files
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed Apr 13, 2014
1 parent 49efd1a commit 73e431a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/core/indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/core/zipfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void ZipFile::Read(void *data, size_t size) {
z.next_in = reinterpret_cast<Bytef*>(&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:
Expand Down

0 comments on commit 73e431a

Please sign in to comment.