diff --git a/support/3rd_party/src/utils/file.cpp b/support/3rd_party/src/utils/file.cpp index c8e5902c..4ac4f20d 100644 --- a/support/3rd_party/src/utils/file.cpp +++ b/support/3rd_party/src/utils/file.cpp @@ -109,10 +109,11 @@ auto file::read_(unsigned char *data, std::size_t to_read, std::uint64_t offset, static_cast(to_read)); if (total_read != nullptr) { auto after = stream_.tellg(); - if (after == -1) { + if (after >= 0) { + (*total_read) = static_cast(after - before); + } else if (after == -1 && stream_.fail()) { throw std::runtime_error("failed to tellg() after read"); } - (*total_read) = static_cast(after - before); } return true;