Handle read errors properly

custom
jacqueline 1 year ago
parent 968d545d67
commit 1494e08ea2
  1. 5
      src/codecs/source_buffer.cpp

@ -40,8 +40,9 @@ auto SourceBuffer::Refill(IStream* src) -> bool {
} }
bool eof = false; bool eof = false;
AddBytes([&](cpp::span<std::byte> buf) -> size_t { AddBytes([&](cpp::span<std::byte> buf) -> size_t {
size_t bytes_read = src->Read(buf); ssize_t bytes_read = src->Read(buf);
eof = bytes_read == 0; // Treat read errors as EOF.
eof = bytes_read <= 0;
return bytes_read; return bytes_read;
}); });
return eof; return eof;

Loading…
Cancel
Save