zlib/backport-Fix-bug-when-using-gzflush-with-a-very-small-buffer.patch
2024-08-13 07:36:01 +00:00

27 lines
933 B
Diff

From d98251478246c8ef2f405d76e4ef1678c14d7eda Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Mon, 14 Aug 2023 17:01:54 -0700
Subject: [PATCH] Fix bug when using gzflush() with a very small buffer.
Reference:https://github.com/madler/zlib/commit/d98251478246c8ef2f405d76e4ef1678c14d7eda
Conflict:NA
---
gzlib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gzlib.c b/gzlib.c
index 2b446c448..29fc4486f 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -308,8 +308,8 @@ int ZEXPORT gzbuffer(gzFile file, unsigned size) {
/* check and set requested size */
if ((size << 1) < size)
return -1; /* need to be able to double it */
- if (size < 2)
- size = 2; /* need two bytes to check magic header */
+ if (size < 8)
+ size = 8; /* needed to behave well with flushing */
state->want = size;
return 0;
}