summaryrefslogtreecommitdiff
path: root/src/fl_utf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fl_utf.c')
-rw-r--r--src/fl_utf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/fl_utf.c b/src/fl_utf.c
index 64d715261..b30ca82c4 100644
--- a/src/fl_utf.c
+++ b/src/fl_utf.c
@@ -151,7 +151,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
} else if (c < 0xc2) {
goto FAIL;
}
- if (p+1 >= end || (p[1]&0xc0) != 0x80) goto FAIL;
+ if ( (end && p+1 >= end) || (p[1]&0xc0) != 0x80) goto FAIL;
if (c < 0xe0) {
if (len) *len = 2;
return
@@ -173,7 +173,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
#endif
} else if (c < 0xf0) {
UTF8_3:
- if (p+2 >= end || (p[2]&0xc0) != 0x80) goto FAIL;
+ if ( (end && p+2 >= end) || (p[2]&0xc0) != 0x80) goto FAIL;
if (len) *len = 3;
return
((p[0] & 0x0f) << 12) +
@@ -184,7 +184,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
goto UTF8_4;
} else if (c < 0xf4) {
UTF8_4:
- if (p+3 >= end || (p[2]&0xc0) != 0x80 || (p[3]&0xc0) != 0x80) goto FAIL;
+ if ( (end && p+3 >= end) || (p[2]&0xc0) != 0x80 || (p[3]&0xc0) != 0x80) goto FAIL;
if (len) *len = 4;
#if STRICT_RFC3629
/* RFC 3629 says all codes ending in fffe or ffff are illegal: */