From a10e6e99d40721ea7cacab1c340f2d81b27770d4 Mon Sep 17 00:00:00 2001 From: Ben Payne Date: Mon, 10 Nov 2014 11:42:49 -0500 Subject: [PATCH] Fix read past end of array --- Engine/source/core/strings/unicode.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Engine/source/core/strings/unicode.cpp b/Engine/source/core/strings/unicode.cpp index b6c915e05..0dee6f3ef 100644 --- a/Engine/source/core/strings/unicode.cpp +++ b/Engine/source/core/strings/unicode.cpp @@ -601,10 +601,13 @@ bool chompUTF8BOM( const char *inString, char **outStringPtr ) { *outStringPtr = const_cast( inString ); - U8 bom[4]; - dMemcpy( bom, inString, 4 ); - - bool valid = isValidUTF8BOM( bom ); + bool valid = false; + if (inString[0] && inString[1] && inString[2]) + { + U8 bom[4]; + dMemcpy(bom, inString, 4); + valid = isValidUTF8BOM(bom); + } // This is hackey, but I am not sure the best way to do it at the present. // The only valid BOM is a UTF8 BOM, which is 3 bytes, even though we read