summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-01-24 16:41:28 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-01-24 16:41:40 (GMT)
commite9500bd770496b47b32bb450b06e6f204777338b (patch)
treea0ce548fe50eee26fe21fa973970396bc3d2c2a6 /Source
parent7e72a179a92bfbc8e73a96382466a73e5862e7a8 (diff)
parent0bd6009a0c368e7ddd1b96284b11d1e8f5312f6a (diff)
downloadCMake-e9500bd770496b47b32bb450b06e6f204777338b.zip
CMake-e9500bd770496b47b32bb450b06e6f204777338b.tar.gz
CMake-e9500bd770496b47b32bb450b06e6f204777338b.tar.bz2
Merge topic 'utf8-decode-empty'
0bd6009a0c cm_utf8: Fail on empty input range Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6885
Diffstat (limited to 'Source')
-rw-r--r--Source/cm_utf8.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Source/cm_utf8.c b/Source/cm_utf8.c
index 62e7e8c..b046aef 100644
--- a/Source/cm_utf8.c
+++ b/Source/cm_utf8.c
@@ -42,6 +42,11 @@ static unsigned int const cm_utf8_min[7] = {
const char* cm_utf8_decode_character(const char* first, const char* last,
unsigned int* pc)
{
+ /* We need at least one byte. */
+ if (first == last) {
+ return 0;
+ }
+
/* Count leading ones in the first byte. */
unsigned char c = (unsigned char)*first++;
unsigned char const ones = cm_utf8_ones[c];