зеркало из https://github.com/github/ruby.git
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:
Родитель
d8182739c7
Коммит
c8c539a198
|
@ -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>
|
||||
|
||||
* 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:
|
||||
fptr = RFILE(obj)->fptr;
|
||||
dump_append(dc, ", \"fd\":%d", fptr->fd);
|
||||
if (fptr)
|
||||
dump_append(dc, ", \"fd\":%d", fptr->fd);
|
||||
break;
|
||||
|
||||
case T_ZOMBIE:
|
||||
|
|
|
@ -266,4 +266,15 @@ class TestObjSpace < Test::Unit::TestCase
|
|||
File.unlink(output)
|
||||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче