mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2072eccda1
commit
2badceae64
3 changed files with 12 additions and 1 deletions
|
@ -1034,6 +1034,7 @@ strscan_aref(VALUE self, VALUE idx)
|
|||
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;
|
||||
|
|
|
@ -718,4 +718,14 @@ class TestStringScanner < Test::Unit::TestCase
|
|||
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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue