ruby-changes:54799
From: nobu <ko1@a...>
Date: Thu, 7 Feb 2019 16:39:51 +0900 (JST)
Subject: [ruby-changes:54799] nobu:r67018 (trunk): * string.c (chopped_length): early return for empty strings
nobu 2019-02-07 16:39:47 +0900 (Thu, 07 Feb 2019) New Revision: 67018 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67018 Log: * string.c (chopped_length): early return for empty strings [Bug #11391] From: Franck Verrot <franck@v...> Modified files: trunk/string.c Index: string.c =================================================================== --- string.c (revision 67017) +++ string.c (revision 67018) @@ -8547,7 +8547,7 @@ chopped_length(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L8547 beg = RSTRING_PTR(str); end = beg + RSTRING_LEN(str); - if (beg > end) return 0; + if (beg >= end) return 0; p = rb_enc_prev_char(beg, end, end, enc); if (!p) return 0; if (p > beg && rb_enc_ascget(p, end, 0, enc) == '\n') { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/