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 3e6dc5372f..7ded9e33cf 100644
--- a/string.c
+++ b/string.c
@@ -1140,7 +1140,7 @@ rb_str_gsub_bang(argc, argv, str)
}
if (RSTRING(str)->len > offset) {
len = bp - buf;
- if (blen - len < RSTRING(str)->len - offset) {
+ if (blen - len < RSTRING(str)->len - offset + 1) {
REALLOC_N(buf, char, len + RSTRING(str)->len - offset + 1);
bp = buf + len;
}