diff options
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -2720,7 +2720,9 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang) if (OBJ_TAINTED(val)) tainted = 1; len = beg - offset; /* copy pre-match substr */ - rb_enc_str_buf_cat(dest, cp, len, str_enc); + if (len) { + rb_enc_str_buf_cat(dest, cp, len, str_enc); + } rb_str_buf_append(dest, val); |