[前][次][番号順一覧][スレッド一覧]

ruby-changes:65556

From: nagachika <ko1@a...>
Date: Sat, 20 Mar 2021 16:30:35 +0900 (JST)
Subject: [ruby-changes:65556] ec779aa56f (ruby_2_7): merge revision(s) f748b911c9157a0bb86f38280ddfba72a55049b6: [Backport #17729]

https://git.ruby-lang.org/ruby.git/commit/?id=ec779aa56f

From ec779aa56f4d6df465e721818d73d0d48fdf03f2 Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Sat, 20 Mar 2021 16:15:35 +0900
Subject: merge revision(s) f748b911c9157a0bb86f38280ddfba72a55049b6: [Backport
 #17729]

	Fix infinite loop at illegal sequence [Bug #17729]

	As mblen returns -1 on failure, skip the first byte and try the
	succeeding bytes in that case.

	Close https://github.com/ruby/ruby/pull/4281
	---
	 eval_intern.h                 | 11 ++++++++++-
	 test/ruby/test_rubyoptions.rb |  5 +++++
	 2 files changed, 15 insertions(+), 1 deletion(-)
---
 eval_intern.h                 | 11 ++++++++++-
 test/ruby/test_rubyoptions.rb |  5 +++++
 version.h                     |  2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/eval_intern.h b/eval_intern.h
index aa07ce3..a8eb828 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -291,7 +291,16 @@ VALUE rb_ec_backtrace_location_ary(const rb_execution_context_t *ec, long lev, l https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L291
 
 #ifndef CharNext		/* defined as CharNext[AW] on Windows. */
 # ifdef HAVE_MBLEN
-#  define CharNext(p) ((p) + mblen((p), RUBY_MBCHAR_MAXSIZE))
+#  define CharNext(p) rb_char_next(p)
+static inline const char *
+rb_char_next(const char *p)
+{
+    if (p) {
+        int len = mblen(p, RUBY_MBCHAR_MAXSIZE);
+        p += len > 0 ? len : 1;
+    }
+    return p;
+}
 # else
 #  define CharNext(p) ((p) + 1)
 # endif
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 26e7f5d..2842b63 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -1069,6 +1069,11 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L1069
     end
   end
 
+  def test_rubylib_invalid_encoding
+    env = {"RUBYLIB"=>"\xFF", "LOCALE"=>"en_US.UTF-8", "LC_ALL"=>"en_US.UTF-8"}
+    assert_ruby_status([env, "-e;"])
+  end
+
   def test_null_script
     skip "#{IO::NULL} is not a character device" unless File.chardev?(IO::NULL)
     assert_in_out_err([IO::NULL], success: true)
diff --git a/version.h b/version.h
index ce6610c..538cd8a 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 3
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 176
+#define RUBY_PATCHLEVEL 177
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 3
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]