diff --git a/tdutils/td/utils/port/FileFd.cpp b/tdutils/td/utils/port/FileFd.cpp index 866806490..0448d153d 100644 --- a/tdutils/td/utils/port/FileFd.cpp +++ b/tdutils/td/utils/port/FileFd.cpp @@ -7,8 +7,6 @@ #include "td/utils/port/FileFd.h" #if TD_PORT_WINDOWS -#include "td/utils/misc.h" // for narrow_cast - #include "td/utils/port/Stat.h" #include "td/utils/port/wstring_convert.h" #endif @@ -222,7 +220,7 @@ Result FileFd::read(MutableSlice slice) { #if TD_PORT_POSIX auto bytes_read = detail::skip_eintr([&] { return ::read(native_fd, slice.begin(), slice.size()); }); bool success = bytes_read >= 0; - bool is_eof = narrow_cast(bytes_read) < slice.size(); + bool is_eof = success && narrow_cast(bytes_read) < slice.size(); #elif TD_PORT_WINDOWS DWORD bytes_read = 0; BOOL success = ReadFile(native_fd, slice.data(), narrow_cast(slice.size()), &bytes_read, nullptr);