diff --git a/src/file.cpp b/src/file.cpp index 28fea84b6..be99fe31d 100755 --- a/src/file.cpp +++ b/src/file.cpp @@ -204,6 +204,7 @@ namespace libtorrent size_type read(char* buf, size_type num_bytes) { + assert(num_bytes > 0); assert(m_open_mode & mode_in); assert(m_fd != -1); @@ -212,7 +213,7 @@ namespace libtorrent #else size_type ret = ::read(m_fd, buf, num_bytes); #endif - if (ret == -1) + if (ret == -1 || ret == 0) { std::stringstream msg; msg << "read failed: " << strerror(errno);