From a35e279b8a7cd5cac4ffa2d77b090da28bd3f4c7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 20 Mar 2010 23:06:52 +0200 Subject: [PATCH] Fix memory corruption in rainbow colors --- src/resources/dye.cpp | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 85a87aa..1cf1742 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -107,6 +107,9 @@ void DyePalette::getColor(int intensity, int color[3]) const int i = intensity * last / 255; int t = intensity * last % 255; + if (j >= last) + j = -1; + int j = t != 0 ? i : i - 1; // Get the exact color if any, the next color otherwise. int r2 = mColors[j + 1].value[0], -- 1.7.0.2