aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-19 09:54:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-19 09:54:44 +0000
commit1bd09d5d5d3bdcc447f21405ef6cd9fa4b95e4f6 (patch)
treee30282df63f5d905f8522e321e2529bf97c26c57
parent7b6862e53e85074edea27688f4f88322324b59f3 (diff)
downloadruby-1bd09d5d5d3bdcc447f21405ef6cd9fa4b95e4f6.tar.gz
iseq.c: check srouce type
* iseq.c (rb_iseq_compile_with_option): check srouce type, must be an IO or a String. [ruby-core:69219] [Bug #11159] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--iseq.c1
-rw-r--r--test/ruby/test_iseq.rb7
3 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 371ead37b4..42eb4beb85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue May 19 18:54:41 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * iseq.c (rb_iseq_compile_with_option): check srouce type, must be
+ an IO or a String. [ruby-core:69219] [Bug #11159]
+
Tue May 19 17:15:03 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* lib/benchmark.rb: Update Benchmark documentation and formatting.
diff --git a/iseq.c b/iseq.c
index a1346115e9..367f8b3327 100644
--- a/iseq.c
+++ b/iseq.c
@@ -582,6 +582,7 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE li
if (RB_TYPE_P((src), T_FILE))
node = rb_parser_compile_file_path(parser, file, src, ln);
else {
+ StringValue(src);
node = rb_parser_compile_string_path(parser, file, src, ln);
if (!node) {
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index 4af440ae42..686646ddd8 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -134,4 +134,11 @@ class TestISeq < Test::Unit::TestCase
assert(!op.to_s.match(/^opt_/), "#{op}")
}
end
+
+ def test_invalid_source
+ bug11159 = '[ruby-core:69219] [Bug #11159]'
+ assert_raise(TypeError, bug11159) {ISeq.compile(nil)}
+ assert_raise(TypeError, bug11159) {ISeq.compile(:foo)}
+ assert_raise(TypeError, bug11159) {ISeq.compile(1)}
+ end
end