From e8eff8f5e4a2a0e1dcb0c8e6fb3a9c6f4c24edde Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Mon, 2 Oct 2017 14:39:07 +1100 Subject: [PATCH] Test that flate history copy doesn't go too far. --- test/c/std/flate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/c/std/flate.c b/test/c/std/flate.c index f289fb44..b1ca33a8 100644 --- a/test/c/std/flate.c +++ b/test/c/std/flate.c @@ -352,10 +352,10 @@ void test_puffs_flate_history_partial() { } int j; - for (j = 0; j < fragment_length; j++) { + for (j = -2; j < (int)(fragment_length) + 2; j++) { uint32_t index = (starting_history_index + j) & 0x7FFF; uint8_t got = dec.private_impl.f_history[index]; - uint8_t want = fragment[j]; + uint8_t want = (0 <= j && j < fragment_length) ? fragment[j] : 0; if (got != want) { FAIL("i=%d: starting_history_index=0x%04" PRIX32 ": j=%d: got 0x%02" PRIX8 ", want 0x%02" PRIX8,