Permalink
Browse files

File::Stat#inspect will not raise an exception if passed uninitialize…

…d object
  • Loading branch information...
1 parent a1f921c commit 0aa2bedad516862f38337db76a4a407eae178bfe @Watson1978 Watson1978 committed Aug 24, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 file.c
View
6 file.c
@@ -683,6 +683,12 @@ rb_stat_inspect(VALUE self, SEL sel)
{"ctime", rb_stat_ctime},
};
+ struct stat* st;
+ Data_Get_Struct(self, struct stat, st);
+ if (!st) {
+ return rb_sprintf("#<%s: uninitialized>", rb_obj_classname(self));
+ }
+
str = rb_str_buf_new2("#<");
rb_str_buf_cat2(str, rb_obj_classname(self));
rb_str_buf_cat2(str, " ");

0 comments on commit 0aa2bed

Please sign in to comment.