gzip: uphold rules for basic_streambuf::underflow overrides

This commit is contained in:
Emil J. Tywoniak
2025-03-19 13:43:44 +01:00
parent 79985a2bca
commit a8a5463f57
+6 -1
View File
@@ -62,8 +62,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);