diff --git a/string.c b/string.c index a4f597f2a4..49b0c7add7 100644 --- a/string.c +++ b/string.c @@ -2828,9 +2828,7 @@ rb_str_rstrip_bang(str) e = t = s + RSTRING(str)->len; /* remove trailing spaces */ - t--; - while (s <= t && ISSPACE(*t)) t--; - t++; + while (s < t && ISSPACE(*(t-1))) t--; RSTRING(str)->len = t-s; if (t < e) {