ruby-changes:47390
From: nagachika <ko1@a...>
Date: Sat, 5 Aug 2017 00:55:55 +0900 (JST)
Subject: [ruby-changes:47390] nagachika:r59506 (ruby_2_4): merge revision(s) 59384: [Backport #13759]
nagachika 2017-08-05 00:55:45 +0900 (Sat, 05 Aug 2017) New Revision: 59506 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59506 Log: merge revision(s) 59384: [Backport #13759] strscan.c: fix segfault in aref * ext/strscan/strscan.c (strscan_aref): fix segfault after get_byte or getch which do not apply regexp. [ruby-core:82116] [Bug #13759] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/ext/strscan/strscan.c branches/ruby_2_4/test/strscan/test_stringscanner.rb branches/ruby_2_4/version.h Index: ruby_2_4/test/strscan/test_stringscanner.rb =================================================================== --- ruby_2_4/test/strscan/test_stringscanner.rb (revision 59505) +++ ruby_2_4/test/strscan/test_stringscanner.rb (revision 59506) @@ -718,4 +718,14 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/strscan/test_stringscanner.rb#L718 s.scan(/test strin/) assert_equal('#<StringScanner 10/16 "...strin" @ "g tes...">', s.inspect) end + + def test_aref_without_regex + s = StringScanner.new('abc') + s.get_byte + assert_nil(s[:c]) + assert_nil(s["c"]) + s.getch + assert_nil(s[:c]) + assert_nil(s["c"]) + end end Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 59505) +++ ruby_2_4/version.h (revision 59506) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-08-05" -#define RUBY_PATCHLEVEL 171 +#define RUBY_PATCHLEVEL 172 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 8 Index: ruby_2_4/ext/strscan/strscan.c =================================================================== --- ruby_2_4/ext/strscan/strscan.c (revision 59505) +++ ruby_2_4/ext/strscan/strscan.c (revision 59506) @@ -1034,6 +1034,7 @@ strscan_aref(VALUE self, VALUE idx) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/strscan/strscan.c#L1034 idx = rb_sym2str(idx); /* fall through */ case T_STRING: + if (!p->regex) return Qnil; RSTRING_GETMEM(idx, name, i); i = name_to_backref_number(&(p->regs), p->regex, name, name + i, rb_enc_get(idx)); break; Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 59505) +++ ruby_2_4 (revision 59506) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r59384 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/