diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-08-15 18:18:07 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-08-15 18:18:07 +0000 |
commit | a174dbcd4fc33a0355b92b646ec3a412b1ebbb14 (patch) | |
tree | 724cd6e3e6083a79654b6df65eb3997e59e13c6f | |
parent | c0ec326b7b9508f5d8f710c9e8c3904722df5dce (diff) | |
download | ruby-a174dbcd4fc33a0355b92b646ec3a412b1ebbb14.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | vm_insnhelper.c | 35 |
2 files changed, 18 insertions, 23 deletions
@@ -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 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 24f4e0133d..be8b07ed17 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -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); + return 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; - } + { + 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 val; + return Qundef; } struct opt_case_dispatch_i_arg { |