Skip to content

Commit

Permalink
Get rid of undefined behavior
Browse files Browse the repository at this point in the history
* string.c (rb_str_sub_bang): str and repl can be same.
  [Bug #15946]
  • Loading branch information
nobu committed Jun 21, 2019
1 parent 50841ec commit 8f51da5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion string.c
Original file line number Diff line number Diff line change
Expand Up @@ -5087,7 +5087,7 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
if (rlen != plen) {
memmove(p + beg0 + rlen, p + beg0 + plen, len - beg0 - plen);
}
memcpy(p + beg0, rp, rlen);
memmove(p + beg0, rp, rlen);
len += rlen - plen;
STR_SET_LEN(str, len);
TERM_FILL(&RSTRING_PTR(str)[len], TERM_LEN(str));
Expand Down

0 comments on commit 8f51da5

Please sign in to comment.