summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-06-23 10:50:19 +0900
committerGitHub <[email protected]>2019-06-23 10:50:19 +0900
commit36f1c26d9da7fd916264c7150b2e088955084c42 (patch)
tree1890c987c9a1d6610c6e07c974eb86e1fbc297bf /src
parentf94551ad40c12370770c8e743ba8b39abc430547 (diff)
parent758353902940e43530dbbbab0d9ce6ded5884923 (diff)
downloadmruby-36f1c26d9da7fd916264c7150b2e088955084c42.tar.gz
mruby-36f1c26d9da7fd916264c7150b2e088955084c42.zip
Merge pull request #4525 from dearblue/utf8len-overflow
Fix potential overflow in `utf8len()`
Diffstat (limited to 'src')
-rw-r--r--src/string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c
index bfe73b359..ed58c484b 100644
--- a/src/string.c
+++ b/src/string.c
@@ -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;