diff options
author | Guido van Rossum <guido@python.org> | 1997-01-06 22:53:20 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-01-06 22:53:20 (GMT) |
commit | 541cdd84aceaec11895c31a6f5afe8a60806cee3 (patch) | |
tree | 0d52e821b17ce70ebc52fcce71a30e538671d84a /Objects/intobject.c | |
parent | d81a1baa5fed9e02b2c75191de8fc0106415e3b0 (diff) | |
download | cpython-541cdd84aceaec11895c31a6f5afe8a60806cee3.zip cpython-541cdd84aceaec11895c31a6f5afe8a60806cee3.tar.gz cpython-541cdd84aceaec11895c31a6f5afe8a60806cee3.tar.bz2 |
Fix overflow test for multiply to catch some cases it missed.
Added warning about dependency of float/complex hash on int hash.
Diffstat (limited to 'Objects/intobject.c')
-rw-r--r-- | Objects/intobject.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c index 6264920..3598c90 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -237,6 +237,8 @@ static long int_hash(v) intobject *v; { + /* XXX If this is changed, you also need to change the way + Python's long, float and complex types are hashed. */ long x = v -> ob_ival; if (x == -1) x = -2; @@ -385,13 +387,13 @@ int_mul(v, w) (NB b == bl in this case, and we make a = al) */ y = ah*b; - if (y >= (1L << (LONG_BIT/2))) + if (y >= (1L << (LONG_BIT/2 - 1))) goto bad; a &= (1L << (LONG_BIT/2)) - 1; x = a*b; if (x < 0) goto bad; - x += y << LONG_BIT/2; + x += y << (LONG_BIT/2); if (x < 0) goto bad; ok: |