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

ruby-changes:18617

From: nobu <ko1@a...>
Date: Mon, 24 Jan 2011 21:04:57 +0900 (JST)
Subject: [ruby-changes:18617] Ruby:r30641 (trunk): * error.c (rb_invalid_str): prevent intermediate variable from GC.

nobu	2011-01-24 21:04:47 +0900 (Mon, 24 Jan 2011)

  New Revision: 30641

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

  Log:
    * error.c (rb_invalid_str): prevent intermediate variable from GC.
      [ruby-core:34820]

  Modified files:
    trunk/ChangeLog
    trunk/error.c
    trunk/test/ruby/test_float.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30640)
+++ ChangeLog	(revision 30641)
@@ -1,3 +1,8 @@
+Mon Jan 24 21:04:45 2011  Nobuyoshi Nakada  <nobu@r...>
+
+	* error.c (rb_invalid_str): prevent intermediate variable from GC.
+	  [ruby-core:34820]
+
 Sun Jan 23 23:01:54 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* test/io/console/test_io_console.rb: Don't run test if the system
Index: error.c
===================================================================
--- error.c	(revision 30640)
+++ error.c	(revision 30641)
@@ -970,7 +970,7 @@
 void
 rb_invalid_str(const char *str, const char *type)
 {
-    VALUE s = rb_str_inspect(rb_str_new2(str));
+    volatile VALUE s = rb_str_inspect(rb_str_new2(str));
 
     rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING_PTR(s));
 }
Index: test/ruby/test_float.rb
===================================================================
--- test/ruby/test_float.rb	(revision 30640)
+++ test/ruby/test_float.rb	(revision 30641)
@@ -472,6 +472,11 @@
     assert(Float(o).nan?)
   end
 
+  def test_invalid_str
+    bug4310 = '[ruby-core:34820]'
+    assert_raise(ArgumentError, bug4310) {under_gc_stress {Float('a'*10000)}}
+  end
+
   def test_num2dbl
     assert_raise(TypeError) do
       1.0.step(2.0, "0.5") {}

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

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