From 60de37448671772201e156eae66d503bf70066bc Mon Sep 17 00:00:00 2001 From: ianXian Date: Fri, 9 Mar 2018 09:45:47 -0800 Subject: [PATCH] Convert to unsigned char before applying bit shift operator (#4664) * Convert to unsigned char before applying bit shift operator * convert to const unsigned char inline * convert to unsigned char inline --- include/flatbuffers/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h index e3178e30a..e6540105a 100644 --- a/include/flatbuffers/util.h +++ b/include/flatbuffers/util.h @@ -321,7 +321,7 @@ inline int FromUTF8(const char **in) { break; } } - if ((**in << len) & 0x80) return -1; // Bit after leading 1's must be 0. + if ((static_cast(**in) << len) & 0x80) return -1; // Bit after leading 1's must be 0. if (!len) return *(*in)++; // UTF-8 encoded values with a length are between 2 and 4 bytes. if (len < 2 || len > 4) { return -1; }