mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
marshal.c: rb_check_funcall
* marshal.c (w_object, marshal_dump, marshal_load): use rb_check_funcall if possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2974b00f17
commit
dd2eb69457
2 changed files with 13 additions and 14 deletions
|
@ -1,4 +1,7 @@
|
||||||
Tue Dec 4 16:23:12 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Dec 4 16:23:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* marshal.c (w_object, marshal_dump, marshal_load): use
|
||||||
|
rb_check_funcall if possible.
|
||||||
|
|
||||||
* marshal.c (w_object, marshal_dump, r_object0, marshal_load): use
|
* marshal.c (w_object, marshal_dump, r_object0, marshal_load): use
|
||||||
RB_GC_GUARD() (directly or indirectly) instead of volatile.
|
RB_GC_GUARD() (directly or indirectly) instead of volatile.
|
||||||
|
|
22
marshal.c
22
marshal.c
|
@ -642,11 +642,11 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
|
||||||
w_float(RFLOAT_VALUE(obj), arg);
|
w_float(RFLOAT_VALUE(obj), arg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
VALUE v;
|
||||||
|
|
||||||
arg->infection |= (int)FL_TEST(obj, MARSHAL_INFECTION);
|
arg->infection |= (int)FL_TEST(obj, MARSHAL_INFECTION);
|
||||||
|
|
||||||
if (rb_obj_respond_to(obj, s_mdump, TRUE)) {
|
if (rb_obj_respond_to(obj, s_mdump, TRUE)) {
|
||||||
VALUE v;
|
|
||||||
|
|
||||||
st_add_direct(arg->data, obj, arg->data->num_entries);
|
st_add_direct(arg->data, obj, arg->data->num_entries);
|
||||||
|
|
||||||
v = rb_funcall2(obj, s_mdump, 0, 0);
|
v = rb_funcall2(obj, s_mdump, 0, 0);
|
||||||
|
@ -658,13 +658,12 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
|
||||||
if (hasiv) w_ivar(obj, ivtbl, &c_arg);
|
if (hasiv) w_ivar(obj, ivtbl, &c_arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rb_obj_respond_to(obj, s_dump, TRUE)) {
|
v = INT2NUM(limit);
|
||||||
VALUE v;
|
v = rb_check_funcall(obj, s_dump, 1, &v);
|
||||||
|
if (v != Qundef) {
|
||||||
st_table *ivtbl2 = 0;
|
st_table *ivtbl2 = 0;
|
||||||
int hasiv2;
|
int hasiv2;
|
||||||
|
|
||||||
v = INT2NUM(limit);
|
|
||||||
v = rb_funcall2(obj, s_dump, 1, &v);
|
|
||||||
check_dump_arg(arg, s_dump);
|
check_dump_arg(arg, s_dump);
|
||||||
if (!RB_TYPE_P(v, T_STRING)) {
|
if (!RB_TYPE_P(v, T_STRING)) {
|
||||||
rb_raise(rb_eTypeError, "_dump() must return string");
|
rb_raise(rb_eTypeError, "_dump() must return string");
|
||||||
|
@ -834,12 +833,12 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
|
||||||
{
|
{
|
||||||
VALUE v;
|
VALUE v;
|
||||||
|
|
||||||
if (!rb_obj_respond_to(obj, s_dump_data, TRUE)) {
|
v = rb_check_funcall(obj, s_dump_data, 0, 0);
|
||||||
|
if (v == Qundef) {
|
||||||
rb_raise(rb_eTypeError,
|
rb_raise(rb_eTypeError,
|
||||||
"no _dump_data is defined for class %s",
|
"no _dump_data is defined for class %s",
|
||||||
rb_obj_classname(obj));
|
rb_obj_classname(obj));
|
||||||
}
|
}
|
||||||
v = rb_funcall2(obj, s_dump_data, 0, 0);
|
|
||||||
check_dump_arg(arg, s_dump_data);
|
check_dump_arg(arg, s_dump_data);
|
||||||
w_class(TYPE_DATA, obj, arg, TRUE);
|
w_class(TYPE_DATA, obj, arg, TRUE);
|
||||||
w_object(v, arg, limit);
|
w_object(v, arg, limit);
|
||||||
|
@ -948,8 +947,7 @@ marshal_dump(int argc, VALUE *argv)
|
||||||
io_needed();
|
io_needed();
|
||||||
}
|
}
|
||||||
arg->dest = port;
|
arg->dest = port;
|
||||||
if (rb_respond_to(port, s_binmode)) {
|
if (rb_check_funcall(port, s_binmode, 0, 0) != Qundef) {
|
||||||
rb_funcall2(port, s_binmode, 0, 0);
|
|
||||||
check_dump_arg(arg, s_binmode);
|
check_dump_arg(arg, s_binmode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1904,9 +1902,7 @@ marshal_load(int argc, VALUE *argv)
|
||||||
port = v;
|
port = v;
|
||||||
}
|
}
|
||||||
else if (rb_respond_to(port, s_getbyte) && rb_respond_to(port, s_read)) {
|
else if (rb_respond_to(port, s_getbyte) && rb_respond_to(port, s_read)) {
|
||||||
if (rb_respond_to(port, s_binmode)) {
|
rb_check_funcall(port, s_binmode, 0, 0);
|
||||||
rb_funcall2(port, s_binmode, 0, 0);
|
|
||||||
}
|
|
||||||
infection = (int)(FL_TAINT | FL_TEST(port, FL_UNTRUSTED));
|
infection = (int)(FL_TAINT | FL_TEST(port, FL_UNTRUSTED));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue