From a30ea8e92c39e4d17c9d67da45ff363849b35cf4 Mon Sep 17 00:00:00 2001 From: Andrew Short Date: Sun, 13 Jul 2014 00:34:08 +1000 Subject: [PATCH] Fix overflow in STL header colour reading. When reading the STL header for a "COLOR=rgb" part, the bytes were treated as signed chars, when in fact they can range from 0-255. This meant that any value greater than 127 would overflow, leading to an incorrect colour. This change fixes the issue by treating the header as unsigned chars. --- code/STLLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index ebd320c1a..068008d9e 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -348,8 +348,8 @@ bool STLImporter::LoadBinaryFile() bool bIsMaterialise = false; // search for an occurence of "COLOR=" in the header - const char* sz2 = (const char*)mBuffer; - const char* const szEnd = sz2+80; + const unsigned char* sz2 = (const unsigned char*)mBuffer; + const unsigned char* const szEnd = sz2+80; while (sz2 < szEnd) { if ('C' == *sz2++ && 'O' == *sz2++ && 'L' == *sz2++ &&