summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index 924b5e3c92..f1db4eb00d 100644
--- a/string.c
+++ b/string.c
@@ -2719,7 +2719,7 @@ rb_str_inspect(str)
while (p < pend) {
char c = *p++;
int len;
- if (ismbchar(c) && p + (len = mbclen(c)) <= pend) {
+ if (ismbchar(c) && p - 1 + (len = mbclen(c)) <= pend) {
rb_str_buf_cat(result, p - 1, len);
p += len - 1;
}