diff options
author | Brad King <brad.king@kitware.com> | 2022-01-21 15:59:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-01-21 15:59:13 (GMT) |
commit | 0bd6009a0c368e7ddd1b96284b11d1e8f5312f6a (patch) | |
tree | 30a4fff972374e6c0213c165339e87b4547e0a5f /Source | |
parent | 91de0ff599ded1aee72c3ff211ee0b5bea5bc8fc (diff) | |
download | CMake-0bd6009a0c368e7ddd1b96284b11d1e8f5312f6a.zip CMake-0bd6009a0c368e7ddd1b96284b11d1e8f5312f6a.tar.gz CMake-0bd6009a0c368e7ddd1b96284b11d1e8f5312f6a.tar.bz2 |
cm_utf8: Fail on empty input range
Issue: #23132
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cm_utf8.c | 5 |
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]; |