summaryrefslogtreecommitdiff
path: root/Source/cm_utf8.c
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cm_utf8.c')
-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 62e7e8c8c..b046aef38 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];