summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-12-10 07:41:48 -0800
committerYukihiro "Matz" Matsumoto <[email protected]>2013-12-10 07:41:48 -0800
commit882afdea20f344c2a3ed4842a6269fe2b8922493 (patch)
treef901d1383b8fb32b278bdacf6c5a0cf0d8a48eef
parentfa4ae7dd4d02db5d9042f3804e73cf54395152bb (diff)
parentc6ede8ed0299ca9714f0bc00ac1be6d19167128b (diff)
downloadmruby-882afdea20f344c2a3ed4842a6269fe2b8922493.tar.gz
mruby-882afdea20f344c2a3ed4842a6269fe2b8922493.zip
Merge pull request #1607 from h2so5/avoid-recursive-inspection
Avoid recursive instance variable inspections
-rw-r--r--src/variable.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/variable.c b/src/variable.c
index 7ff68cc17..5cb1aabbc 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -563,6 +563,7 @@ inspect_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p)
mrb_value str = *(mrb_value*)p;
const char *s;
size_t len;
+ mrb_value ins;
/* need not to show internal data */
if (RSTRING_PTR(str)[0] == '-') { /* first element */
@@ -575,7 +576,13 @@ inspect_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p)
s = mrb_sym2name_len(mrb, sym, &len);
mrb_str_cat(mrb, str, s, len);
mrb_str_cat(mrb, str, "=", 1);
- mrb_str_append(mrb, str, mrb_inspect(mrb, v));
+ if (mrb_type(v) == MRB_TT_OBJECT) {
+ ins = mrb_any_to_s(mrb, v);
+ }
+ else {
+ ins = mrb_inspect(mrb, v);
+ }
+ mrb_str_append(mrb, str, ins);
return 0;
}