summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/encoding.c b/encoding.c
index 540aa88701..e902f6db0e 100644
--- a/encoding.c
+++ b/encoding.c
@@ -486,7 +486,8 @@ int
rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
{
int n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e);
- if (MBCLEN_CHARFOUND(n))
+ n = MBCLEN_CHARFOUND(n);
+ if (0 < n && n <= e-p)
return n;
else
return 1;