Skip to content

Commit fa8642b

Browse files
committed
gzip: uphold rules for basic_streambuf::underflow overrides
1 parent 00071c1 commit fa8642b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel/gzip.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,13 @@ std::istream::int_type gzip_istream::ibuf::underflow() {
6262
log_assert(gzf && "No gzfile opened\n");
6363
int bytes_read = Zlib::gzread(gzf, buffer, buffer_size);
6464
if (bytes_read <= 0) {
65-
if (Zlib::gzeof(gzf))
65+
if (Zlib::gzeof(gzf)) {
66+
// "On failure, the function ensures that either
67+
// gptr() == nullptr or gptr() == egptr."
68+
// Let's set gptr to egptr
69+
setg(eback(), egptr(), egptr());
6670
return traits_type::eof();
71+
}
6772

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

0 commit comments

Comments
 (0)