Skip to content

Commit

Permalink
gzip: uphold rules for basic_streambuf::underflow overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
widlarizer committed Jan 9, 2025
1 parent cfa3b71 commit ee5043f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernel/gzip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ std::istream::int_type gzip_istream::ibuf::underflow() {
log_assert(gzf && "No gzfile opened\n");
int bytes_read = Zlib::gzread(gzf, buffer, buffer_size);
if (bytes_read <= 0) {
if (Zlib::gzeof(gzf))
if (Zlib::gzeof(gzf)) {
// "On failure, the function ensures that either
// gptr() == nullptr or gptr() == egptr."
// Let's set gptr to egptr
setg(eback(), egptr(), egptr());
return traits_type::eof();
}

int err;
const char* error_msg = Zlib::gzerror(gzf, &err);
Expand Down

0 comments on commit ee5043f

Please sign in to comment.