diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-09 15:08:41 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-09 15:08:41 +0000 |
commit | 487a25d29b33c48b37d10e3b20b5947e823596c7 (patch) | |
tree | 206cc2e5fa5d13c6b7f67b71f624d0038f7c61bb | |
parent | 24cf72029f0c43f59520b88d1eafee4959bcddc1 (diff) |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | numeric.c | 2 |
2 files changed, 7 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Thu Oct 10 00:02:35 2013 Yusuke Endoh <mame@tsg.ne.jp> + + * 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@ruby-lang.org> * object.c (id_for_attr): avoid inadvertent symbol creation. @@ -3443,7 +3443,7 @@ fix_aref(VALUE fix, VALUE idx) 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); } |