aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2016-10-26 22:27:19 +0200
committerWillem Jan Palenstijn2016-10-26 22:30:02 +0200
commit407187161038403f4d5e1ea35841379edfcef47a (patch)
tree0365dfca6a3316356d7c0e7e6f3532e4fa02810f
parentca52f16e08e5be27faf53b5b4161db467ab0d405 (diff)
downloadscummvm-rg350-407187161038403f4d5e1ea35841379edfcef47a.tar.gz
scummvm-rg350-407187161038403f4d5e1ea35841379edfcef47a.tar.bz2
scummvm-rg350-407187161038403f4d5e1ea35841379edfcef47a.zip
MADS: Fix two off-by-ones in Fader::insertionSort
Fixes bug #9631.
-rw-r--r--engines/mads/palette.cpp6
1 files changed, 3 insertions, 3 deletions
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];
}
}