ruby-changes:31143
From: mame <ko1@a...>
Date: Thu, 10 Oct 2013 00:08:48 +0900 (JST)
Subject: [ruby-changes:31143] mame:r43222 (trunk): * numeric.c (fix_aref): avoid a possible undefined behavior.
mame 2013-10-10 00:08:41 +0900 (Thu, 10 Oct 2013) New Revision: 43222 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43222 Log: * numeric.c (fix_aref): avoid a possible undefined behavior. 1L << 63 on 64-bit platform is undefined, at least, according to ISO/IEC 9899 (C99) 6.5.7. Modified files: trunk/ChangeLog trunk/numeric.c Index: ChangeLog =================================================================== --- ChangeLog (revision 43221) +++ ChangeLog (revision 43222) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Oct 10 00:02:35 2013 Yusuke Endoh <mame@t...> + + * numeric.c (fix_aref): avoid a possible undefined behavior. + 1L << 63 on 64-bit platform is undefined, at least, according to + ISO/IEC 9899 (C99) 6.5.7. + Wed Oct 9 23:57:02 2013 Nobuyoshi Nakada <nobu@r...> * object.c (id_for_attr): avoid inadvertent symbol creation. Index: numeric.c =================================================================== --- numeric.c (revision 43221) +++ numeric.c (revision 43222) @@ -3443,7 +3443,7 @@ fix_aref(VALUE fix, VALUE idx) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3443 i = FIX2LONG(idx); if (i < 0) return INT2FIX(0); - if (SIZEOF_LONG*CHAR_BIT-1 < i) { + if (SIZEOF_LONG*CHAR_BIT-1 <= i) { if (val < 0) return INT2FIX(1); return INT2FIX(0); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/