diff options
author | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-15 00:40:38 +0000 |
---|---|---|
committer | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-15 00:40:38 +0000 |
commit | 251c8ee39f4fdbf42a8bd43340add00c08bf06a7 (patch) | |
tree | 958214bb5fa7fb8ca4302036f4b5a0764a268494 | |
parent | ed488e6a04eb924fc19ea7659bdc28013a07ed67 (diff) | |
download | ruby-251c8ee39f4fdbf42a8bd43340add00c08bf06a7.tar.gz |
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`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ext/coverage/coverage.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c index cb70b33af9..c2ccd343d0 100644 --- a/ext/coverage/coverage.c +++ b/ext/coverage/coverage.c @@ -42,6 +42,8 @@ rb_coverage_start(int argc, VALUE *argv, VALUE klass) } 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"))))) |