Skip to content

Commit

Permalink
* error.c (rb_invalid_str): prevent intermediate variable from GC.
Browse files Browse the repository at this point in the history
  [ruby-core:34820]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jan 24, 2011
1 parent b9c0b50 commit 97b8e49
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Mon Jan 24 21:04:45 2011 Nobuyoshi Nakada <[email protected]>

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

Sun Jan 23 23:01:54 2011 KOSAKI Motohiro <[email protected]>

* test/io/console/test_io_console.rb: Don't run test if the system
Expand Down
2 changes: 1 addition & 1 deletion error.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ nometh_err_args(VALUE self)
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));
}
Expand Down
5 changes: 5 additions & 0 deletions test/ruby/test_float.rb
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ def o.to_f; inf = Float::INFINITY; inf/inf; end
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") {}
Expand Down

0 comments on commit 97b8e49

Please sign in to comment.