ruby-changes:56183
From: Nobuyoshi <ko1@a...>
Date: Fri, 21 Jun 2019 22:48:50 +0900 (JST)
Subject: [ruby-changes:56183] Nobuyoshi Nakada: 8f51da5d41 (trunk): Get rid of undefined behavior
https://git.ruby-lang.org/ruby.git/commit/?id=8f51da5d41 From 8f51da5d41f0642d5a971e4223d1ba14643c6398 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 21 Jun 2019 22:42:14 +0900 Subject: Get rid of undefined behavior * string.c (rb_str_sub_bang): str and repl can be same. [Bug #15946] diff --git a/string.c b/string.c index 3feeb8c..5a91f6b 100644 --- a/string.c +++ b/string.c @@ -5087,7 +5087,7 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L5087 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)); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/