Unverified Commit 4a84fa5d authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #5580 from dearblue/static-proc

Fixed occurs `SIGSEGV` with `mrbgems/mruby-method`
parents 01cadd3e b02bd63d
......@@ -9,6 +9,10 @@
mrb_noreturn void mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args);
mrb_value mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p);
// Defined by mruby-proc-ext on which mruby-method depends
mrb_value mrb_proc_parameters(mrb_state *mrb, mrb_value proc);
mrb_value mrb_proc_source_location(mrb_state *mrb, struct RProc *p);
static mrb_value
args_shift(mrb_state *mrb)
{
......@@ -345,28 +349,17 @@ static mrb_value
method_source_location(mrb_state *mrb, mrb_value self)
{
mrb_value proc = mrb_iv_get(mrb, self, MRB_SYM(_proc));
struct RProc *rproc;
struct RClass *orig;
mrb_value ret;
if (mrb_nil_p(proc))
return mrb_nil_value();
rproc = mrb_proc_ptr(proc);
orig = rproc->c;
rproc->c = mrb->proc_class;
ret = mrb_funcall_id(mrb, proc, MRB_SYM(source_location), 0);
rproc->c = orig;
return ret;
return mrb_proc_source_location(mrb, mrb_proc_ptr(proc));
}
static mrb_value
method_parameters(mrb_state *mrb, mrb_value self)
{
mrb_value proc = mrb_iv_get(mrb, self, MRB_SYM(_proc));
struct RProc *rproc;
struct RClass *orig;
mrb_value ret;
if (mrb_nil_p(proc)) {
mrb_value rest = mrb_symbol_value(MRB_SYM(rest));
......@@ -374,12 +367,7 @@ method_parameters(mrb_state *mrb, mrb_value self)
return mrb_ary_new_from_values(mrb, 1, &arest);
}
rproc = mrb_proc_ptr(proc);
orig = rproc->c;
rproc->c = mrb->proc_class;
ret = mrb_funcall_id(mrb, proc, MRB_SYM(parameters), 0);
rproc->c = orig;
return ret;
return mrb_proc_parameters(mrb, proc);
}
static mrb_value
......
......@@ -92,7 +92,7 @@ mrb_kernel_proc(mrb_state *mrb, mrb_value self)
* prc.parameters #=> [[:req, :x], [:opt, :y], [:rest, :other]]
*/
static mrb_value
mrb_value
mrb_proc_parameters(mrb_state *mrb, mrb_value self)
{
struct parameters_type {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment