diff --git a/ChangeLog b/ChangeLog index 3a1f2c7a6b..24d8f517ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Oct 10 00:02:35 2013 Yusuke Endoh + + * 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 * object.c (id_for_attr): avoid inadvertent symbol creation. diff --git a/numeric.c b/numeric.c index 6979b21b65..83ed3e469d 100644 --- a/numeric.c +++ b/numeric.c @@ -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); }