summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro Matz Matsumoto <[email protected]>2013-01-26 00:17:40 +0900
committerYukihiro Matz Matsumoto <[email protected]>2013-01-26 00:17:40 +0900
commit47d7cce66dc79235509130bcfc5ca0d32c21337b (patch)
treeb1d647f6c3cf5f31c14834e8f635cb9dbad0b06a
parenta01343d57eb7fb5f9abfc4bc785d9535443218fd (diff)
downloadmruby-47d7cce66dc79235509130bcfc5ca0d32c21337b.tar.gz
mruby-47d7cce66dc79235509130bcfc5ca0d32c21337b.zip
inspecting anonymous class should not SEGV; close #780
-rw-r--r--src/class.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/class.c b/src/class.c
index b24dd8a08..530fc5ce4 100644
--- a/src/class.c
+++ b/src/class.c
@@ -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;
}