summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-11 02:01:36 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-11 02:01:36 (GMT)
commite5c516c89a62839fd025ae112041ed9a5f06c9d0 (patch)
tree5457f6e76dcfa0d9f0dd2f84ad68036fb6c297ab /test
parent4068d9089adca488546c7ff8b59118eb47a3ade0 (diff)
generator.c: fix infinite recursion
* ext/json/generator/generator.c (generate_json): get rid of unnecessary recursive calls which can cause infinite recursion. T_STRING may not have rb_cString. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rwxr-xr-xtest/json/test_json_generate.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/json/test_json_generate.rb b/test/json/test_json_generate.rb
index 8db0b78..1834290 100755
--- a/test/json/test_json_generate.rb
+++ b/test/json/test_json_generate.rb
@@ -334,4 +334,14 @@ EOT
assert_equal true, JSON.generate(["\xea"])
end
end
+
+ def test_string_subclass
+ s = Class.new(String) do
+ def to_s; self; end
+ undef to_json
+ end
+ assert_nothing_raised(SystemStackError) do
+ assert_equal '[""]', JSON.generate([s.new])
+ end
+ end
end