compat/unsetenv.c: Fix a sparse warning
[gitweb.git] / streaming.c
index f4ab12ba420e99cd08abed1762e8ee7c040261b6..cabcd9d1577d89c5e944a4c12e3a8e6af901078c 100644 (file)
@@ -309,7 +309,7 @@ static read_method_decl(loose)
                        st->z_state = z_done;
                        break;
                }
-               if (status != Z_OK && status != Z_BUF_ERROR) {
+               if (status != Z_OK && (status != Z_BUF_ERROR || total_read < sz)) {
                        git_inflate_end(&st->z);
                        st->z_state = z_error;
                        return -1;