/*
* call-seq:
* Proc.load(str) => UnboundProc
*
* Load a Proc from a String. When it is loaded, it will be an
* UnboundProc, until it is bound to a Binding with UnboundProc#bind.
*/
static VALUE proc_load(VALUE klass, VALUE str)
{
#ifdef RUBY_HAS_YARV
VALUE iseq = marshal_load(str);
return create_proc(rb_cUnboundProc, Qnil, iseq_check(iseq));
#else
VALUE arr = marshal_load(str);
NODE * body, * var;
if( ruby_safe_level >= 4
|| (ruby_safe_level >= 1 && OBJ_TAINTED(str)))
{
/* no playing with knives in the sandbox */
rb_raise(rb_eSecurityError, "Insecure: can't load proc");
}
Check_Type(arr, T_ARRAY);
body = unwrap_node(RARRAY_PTR(arr)[0]);
var = unwrap_node(RARRAY_PTR(arr)[1]);
return create_proc(rb_cUnboundProc, Qnil, body, var);
#endif
}