From 59001c6acd157e52f3c4970ccc6fe3c3676590ab Mon Sep 17 00:00:00 2001 From: tb Date: Sun, 21 Jan 2024 07:46:16 +0000 Subject: [PATCH] Sync with upstream as of Jan 20 No change of compiled code: the bug fix in check_match() affects ZLIB_DEBUG builds only and the Z_ARG macro is unused. --- lib/libz/deflate.c | 20 ++++++++++++++------ lib/libz/zconf.h | 8 -------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/libz/deflate.c b/lib/libz/deflate.c index 8cfe4471295..a29653e6b67 100644 --- a/lib/libz/deflate.c +++ b/lib/libz/deflate.c @@ -1552,13 +1552,21 @@ local uInt longest_match(deflate_state *s, IPos cur_match) { */ local void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); + Bytef *back = s->window + (int)match, *here = s->window + start; + IPos len = length; + if (match == (IPos)-1) { + /* match starts one byte before the current window -- just compare the + subsequent length-1 bytes */ + back++; + here++; + len--; + } + if (zmemcmp(back, here, len) != EQUAL) { + fprintf(stderr, " start %u, match %d, length %d\n", + start, (int)match, length); do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); + fprintf(stderr, "(%02x %02x)", *back++, *here++); + } while (--len != 0); z_error("invalid match"); } if (z_verbose > 1) { diff --git a/lib/libz/zconf.h b/lib/libz/zconf.h index 7c1dc4fc61d..5b8331ab89b 100644 --- a/lib/libz/zconf.h +++ b/lib/libz/zconf.h @@ -298,14 +298,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have -- 2.20.1