ruby-changes:47797
From: yui-knk <ko1@a...>
Date: Fri, 15 Sep 2017 09:40:46 +0900 (JST)
Subject: [ruby-changes:47797] yui-knk:r59915 (trunk): ext/coverage/coverage.c (rb_coverage_start): Ensure `opt` is a hash
yui-knk 2017-09-15 09:40:38 +0900 (Fri, 15 Sep 2017) New Revision: 59915 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59915 Log: ext/coverage/coverage.c (rb_coverage_start): Ensure `opt` is a hash Ensure `opt` is a hash before using `rb_hash_lookup` to `opt`. This will prevent SEGV when an inappropriate object (i.e. an array) is passed to `opt`. Modified files: trunk/ext/coverage/coverage.c Index: ext/coverage/coverage.c =================================================================== --- ext/coverage/coverage.c (revision 59914) +++ ext/coverage/coverage.c (revision 59915) @@ -42,6 +42,8 @@ rb_coverage_start(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ext/coverage/coverage.c#L42 } else { mode = 0; + opt = rb_convert_type(opt, T_HASH, "Hash", "to_hash"); + if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("lines"))))) mode |= COVERAGE_TARGET_LINES; if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("branches"))))) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/