From 407187161038403f4d5e1ea35841379edfcef47a Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 26 Oct 2016 22:27:19 +0200 Subject: MADS: Fix two off-by-ones in Fader::insertionSort Fixes bug #9631. --- engines/mads/palette.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/mads') diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp index 7651fe8e65..de870295a5 100644 --- a/engines/mads/palette.cpp +++ b/engines/mads/palette.cpp @@ -665,15 +665,15 @@ void Fader::insertionSort(int size, byte *id, byte *value) { int moveCount = size - arrIndex - 1; if (moveCount > 0) { - Common::copy(idP + 1, idP + moveCount + 2, idP); - Common::copy(valueP + 1, valueP + moveCount + 2, valueP); + Common::copy(idP + 1, idP + moveCount + 1, idP); + Common::copy(valueP + 1, valueP + moveCount + 1, valueP); } // Scan for insert spot int idx = 0; if (endIndex > 0) { bool breakFlag = false; - for (; idx <= endIndex && !breakFlag; ++idx) { + for (; idx <= endIndex - 1 && !breakFlag; ++idx) { breakFlag = savedId < id[idx]; } } -- cgit v1.2.3