diff options
author | sorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-20 20:50:20 +0000 |
---|---|---|
committer | sorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-20 20:50:20 +0000 |
commit | 813e00ad2f66bb6903a46185f984476767ce3b95 (patch) | |
tree | fb5ba26ee6b53837badc8a5dfc4837bbfb44d324 | |
parent | db952b4fdca3d655602b75f0a9a3140096235bdd (diff) | |
download | ruby-813e00ad2f66bb6903a46185f984476767ce3b95.tar.gz |
* ext/objspace/objspace_dump.c(dump_object): Return empty JSON object when
passed object is a special const, instead of SEGV.
Based patch by Kohei Suzuki (eagletmt). [ruby-core:69692] [Bug #11291]
* test/objspace/test_objspace.rb(test_dump_special_consts): Test for above fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ext/objspace/objspace_dump.c | 5 | ||||
-rw-r--r-- | test/objspace/test_objspace.rb | 9 |
3 files changed, 23 insertions, 0 deletions
@@ -1,3 +1,12 @@ +Sun Jun 21 05:31:41 2015 Shota Fukumori <her@sorah.jp> + + * ext/objspace/objspace_dump.c(dump_object): Return empty JSON object when + passed object is a special const, instead of SEGV. + Based patch by Kohei Suzuki (eagletmt). [ruby-core:69692] [Bug #11291] + + * test/objspace/test_objspace.rb(test_dump_special_consts): Test for above fix. + + Sat Jun 20 03:56:58 2015 Yusuke Endoh <mame@ruby-lang.org> * enc/make_encmake.rb: the list of encoding extension libraries must diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index 7e082f96bb..4e4698868f 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -149,6 +149,11 @@ dump_object(VALUE obj, struct dump_config *dc) ID flags[RB_OBJ_GC_FLAGS_MAX]; size_t n, i; + if (SPECIAL_CONST_P(obj)) { + dump_append(dc, "{}"); + return; + } + dc->cur_obj = obj; dc->cur_obj_references = 0; dc->cur_obj_klass = BUILTIN_TYPE(obj) == T_NODE ? 0 : RBASIC_CLASS(obj); diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 0f0c904511..01f31cc784 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -243,6 +243,15 @@ class TestObjSpace < Test::Unit::TestCase assert_match /"method":"#{loc.base_label}"/, info end + def test_dump_special_consts + # [ruby-core:69692] [Bug #11291] + assert_equal('{}', ObjectSpace.dump(nil)) + assert_equal('{}', ObjectSpace.dump(true)) + assert_equal('{}', ObjectSpace.dump(false)) + assert_equal('{}', ObjectSpace.dump(0)) + assert_equal('{}', ObjectSpace.dump(:foo)) + end + def test_dump_all entry = /"bytesize":11, "value":"TEST STRING", "encoding":"UTF-8", "file":"-", "line":4, "method":"dump_my_heap_please", "generation":/ |