summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/string.c b/string.c
index 7f5bf6ae72..2436171777 100644
--- a/string.c
+++ b/string.c
@@ -851,6 +851,9 @@ str_replace(str, beg, len, val)
RSTRING(str)->ptr+beg+len,
RSTRING(str)->len-(beg+len));
}
+ if (RSTRING(str)->len < beg && len < 0) {
+ MEMZERO(RSTRING(str)->ptr+RSTRING(str)->len, char, -len);
+ }
memcpy(RSTRING(str)->ptr+beg, RSTRING(val)->ptr, RSTRING(val)->len);
RSTRING(str)->len += RSTRING(val)->len - len;
RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
@@ -1407,7 +1410,7 @@ str_inspect(str)
*b++ = c;
*b++ = *p++;
}
- else if (c & 0x80) {
+ else if ((c & 0x80) && current_mbctype != MBCTYPE_EUC) {
CHECK(1);
*b++ = c;
}