mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ext/objspace: Check fptr before trying to dump FILE object fd
Patch by Scott Francis. Closes GH-562. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d8182739c7
commit
c8c539a198
3 changed files with 20 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Tue Mar 11 06:54:00 2014 Scott Francis <scott.francis@shopify.com>
|
||||||
|
|
||||||
|
* ext/objspace/objspace_dump.c: Check fptr before trying to dump RFILE
|
||||||
|
object fd. [GH-562]
|
||||||
|
|
||||||
|
* test/objspace/test_objspace.rb: add test
|
||||||
|
|
||||||
Tue Mar 11 02:04:36 2014 NARUSE, Yui <naruse@ruby-lang.org>
|
Tue Mar 11 02:04:36 2014 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* vm_dump.c (rb_vm_bugreport): show vm maps on FreeBSD.
|
* vm_dump.c (rb_vm_bugreport): show vm maps on FreeBSD.
|
||||||
|
|
|
@ -230,7 +230,8 @@ dump_object(VALUE obj, struct dump_config *dc)
|
||||||
|
|
||||||
case T_FILE:
|
case T_FILE:
|
||||||
fptr = RFILE(obj)->fptr;
|
fptr = RFILE(obj)->fptr;
|
||||||
dump_append(dc, ", \"fd\":%d", fptr->fd);
|
if (fptr)
|
||||||
|
dump_append(dc, ", \"fd\":%d", fptr->fd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_ZOMBIE:
|
case T_ZOMBIE:
|
||||||
|
|
|
@ -266,4 +266,15 @@ class TestObjSpace < Test::Unit::TestCase
|
||||||
File.unlink(output)
|
File.unlink(output)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_dump_uninitialized_file
|
||||||
|
assert_in_out_err(%[-robjspace], <<-RUBY) do |output, error|
|
||||||
|
puts ObjectSpace.dump(File.allocate)
|
||||||
|
RUBY
|
||||||
|
assert_equal [], error
|
||||||
|
json = JSON.load(output.join)
|
||||||
|
assert_equal "FILE", json["type"]
|
||||||
|
assert_nil json["fd"]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue