[前][次][番号順一覧][スレッド一覧]

ruby-changes:38460

From: nobu <ko1@a...>
Date: Tue, 19 May 2015 18:55:08 +0900 (JST)
Subject: [ruby-changes:38460] nobu:r50541 (trunk): iseq.c: check srouce type

nobu	2015-05-19 18:54:44 +0900 (Tue, 19 May 2015)

  New Revision: 50541

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50541

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/iseq.c
    trunk/test/ruby/test_iseq.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50540)
+++ ChangeLog	(revision 50541)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue May 19 18:54:41 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* lib/benchmark.rb: Update Benchmark documentation and formatting.
Index: iseq.c
===================================================================
--- iseq.c	(revision 50540)
+++ iseq.c	(revision 50541)
@@ -582,6 +582,7 @@ rb_iseq_compile_with_option(VALUE src, V https://github.com/ruby/ruby/blob/trunk/iseq.c#L582
 	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) {
Index: test/ruby/test_iseq.rb
===================================================================
--- test/ruby/test_iseq.rb	(revision 50540)
+++ test/ruby/test_iseq.rb	(revision 50541)
@@ -134,4 +134,11 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L134
       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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]