1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* vm_insnhelper.c (opt_eq_func): fix optimization bug. This issue

was found out and debugged with Takuto Hayashi at Security and
  Programming camp 2009.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2009-08-15 18:18:07 +00:00
parent c0ec326b7b
commit a174dbcd4f
2 changed files with 20 additions and 25 deletions

View file

@ -1,3 +1,9 @@
Sun Aug 16 03:06:59 2009 Koichi Sasada <ko1@atdot.net>
* vm_insnhelper.c (opt_eq_func): fix optimization bug. This issue
was found out and debugged with Takuto Hayashi at Security and
Programming camp 2009.
Sun Aug 16 01:10:00 2009 NARUSE, Yui <naruse@ruby-lang.org>
* regparse.c (add_ctype_to_cc_by_range): fix the first

View file

@ -1547,16 +1547,9 @@ inline
VALUE
opt_eq_func(VALUE recv, VALUE obj, IC ic)
{
VALUE val = Qundef;
if (FIXNUM_2_P(recv, obj) &&
BASIC_OP_UNREDEFINED_P(BOP_EQ)) {
if (recv == obj) {
val = Qtrue;
}
else {
val = Qfalse;
}
return (recv == obj) ? Qtrue : Qfalse;
}
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
if (HEAP_CLASS_OF(recv) == rb_cFloat &&
@ -1566,31 +1559,27 @@ opt_eq_func(VALUE recv, VALUE obj, IC ic)
double b = RFLOAT_VALUE(obj);
if (isnan(a) || isnan(b)) {
val = Qfalse;
}
else if (a == b) {
val = Qtrue;
}
else {
val = Qfalse;
return Qfalse;
}
return (a == b) ? Qtrue : Qfalse;
}
else if (HEAP_CLASS_OF(recv) == rb_cString &&
HEAP_CLASS_OF(obj) == rb_cString &&
BASIC_OP_UNREDEFINED_P(BOP_EQ)) {
val = rb_str_equal(recv, obj);
}
else {
const rb_method_entry_t *me = vm_method_search(idEq, CLASS_OF(recv), ic);
extern VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
if (check_cfunc(me, rb_obj_equal)) {
return recv == obj ? Qtrue : Qfalse;
}
return rb_str_equal(recv, obj);
}
}
return val;
{
const rb_method_entry_t *me = vm_method_search(idEq, CLASS_OF(recv), ic);
extern VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
if (check_cfunc(me, rb_obj_equal)) {
return recv == obj ? Qtrue : Qfalse;
}
}
return Qundef;
}
struct opt_case_dispatch_i_arg {