Merge pull request #4525 from dearblue/utf8len-overflow

Fix potential overflow in `utf8len()`
This commit is contained in:
Yukihiro "Matz" Matsumoto
2019-06-23 10:50:19 +09:00
committed by GitHub
+1 -1
View File
@@ -234,7 +234,7 @@ utf8len(const char* p, const char* e)
mrb_int i;
len = utf8len_codepage[(unsigned char)*p];
if (p + len > e) return 1;
if (len > e - p) return 1;
for (i = 1; i < len; ++i)
if ((p[i] & 0xc0) != 0x80)
return 1;