mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix crash if #inspect does not return a string value
This commit is contained in:
@@ -11,8 +11,13 @@
|
||||
static void
|
||||
p(mrb_state *mrb, mrb_value obj)
|
||||
{
|
||||
obj = mrb_funcall(mrb, obj, "inspect", 0);
|
||||
fwrite(RSTRING_PTR(obj), RSTRING_LEN(obj), 1, stdout);
|
||||
mrb_value val;
|
||||
|
||||
val = mrb_funcall(mrb, obj, "inspect", 0);
|
||||
if (!mrb_string_p(val)) {
|
||||
val = mrb_obj_as_string(mrb, obj);
|
||||
}
|
||||
fwrite(RSTRING_PTR(val), RSTRING_LEN(val), 1, stdout);
|
||||
putc('\n', stdout);
|
||||
}
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user