From 24a796c3bc9167faa35bc87717d5c72e5bd85eb3 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Tue, 19 Jan 2016 17:54:51 +0000 Subject: [PATCH] fix #2778: encode_chunk_repeat reads out of range memory --- src/util/sawyercoding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/sawyercoding.c b/src/util/sawyercoding.c index 4ae6edc537..4d725f99ea 100644 --- a/src/util/sawyercoding.c +++ b/src/util/sawyercoding.c @@ -417,7 +417,7 @@ static size_t encode_chunk_repeat(const uint8 *src_buffer, uint8 *dst_buffer, si bestRepeatCount = 0; for (repeatIndex = searchIndex; repeatIndex <= searchEnd; repeatIndex++) { repeatCount = 0; - maxRepeatCount = min(7, searchEnd - repeatIndex); + maxRepeatCount = min(min(7, searchEnd - repeatIndex), length - i - 1); for (j = 0; j <= maxRepeatCount; j++) { assert(repeatIndex + j < length); assert(i + j < length);