diff --git a/ChangeLog b/ChangeLog index 9b682b0d3a..23dba079b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Mar 24 17:08:52 2009 Akinori MUSHA + + * io.c (rb_io_inspect): Cannot access fptr->fd if fptr is NULL. + This fixes a coredump caused by: ruby -e "class X < IO; def + initialize; end; end; p X.new.inspect" + Mon Mar 23 22:01:00 2009 Tanaka Akira * time.c (time_timespec): use NUM2TIMET. diff --git a/io.c b/io.c index 0a984a18db..19ea6132be 100644 --- a/io.c +++ b/io.c @@ -1387,8 +1387,9 @@ rb_io_inspect(VALUE obj) const char *st = ""; fptr = RFILE(rb_io_taint_check(obj))->fptr; + if (!fptr) return rb_any_to_s(obj); cname = rb_obj_classname(obj); - if (!fptr || NIL_P(fptr->pathv)) { + if (NIL_P(fptr->pathv)) { if (fptr->fd < 0) { path = ""; st = "(closed)";