inspecting anonymous class should not SEGV; close #780

This commit is contained in:
Yukihiro Matz Matsumoto
2013-01-26 00:17:40 +09:00
parent a01343d57e
commit 47d7cce66d
+6 -1
View File
@@ -1211,7 +1211,12 @@ const char*
mrb_class_name(mrb_state *mrb, struct RClass* c)
{
mrb_value path = mrb_class_path(mrb, c);
if (mrb_nil_p(path)) return 0;
if (mrb_nil_p(path)) {
char buf[32];
snprintf(buf, 32, "#<Class:%p>", c);
path = mrb_str_new_cstr(mrb, buf);
}
return mrb_str_ptr(path)->ptr;
}