From b01ef625ad4d8ac640f4480c07d50fd8d0bb0f73 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Thu, 9 May 2024 20:11:24 +0300 Subject: [PATCH] Fix rare case of UDP download failing to decompress. If inflate() produces exactly sizeof(buffer) output, progress may not be possible if all input has been consumed. As per zlib usage example, Z_BUF_ERROR must be ignored in this case. --- src/client/download.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/download.c b/src/client/download.c index fc97cbfc3..e9d15654e 100644 --- a/src/client/download.c +++ b/src/client/download.c @@ -329,7 +329,7 @@ static bool inflate_udp_download(byte *data, int size, int decompressed_size) z->avail_out = sizeof(buffer); ret = inflate(z, Z_SYNC_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) { + if (ret != Z_OK && ret != Z_STREAM_END && ret != Z_BUF_ERROR) { Com_EPrintf("[UDP] Error %d decompressing download\n", ret); finish_udp_download(NULL); return false;