[Python-checkins] cpython (2.7): Don't left shift negative values. Use an unsigned value instead to avoid

gregory.p.smith python-checkins at python.org
Wed Aug 5 01:30:56 CEST 2015


https://hg.python.org/cpython/rev/50ea0c4bfbee
changeset:   97256:50ea0c4bfbee
branch:      2.7
parent:      97250:cfd768814ca3
user:        Gregory P. Smith <greg at krypto.org>
date:        Tue Aug 04 16:29:00 2015 -0700
summary:
  Don't left shift negative values.  Use an unsigned value instead to avoid
undefined behavior.

files:
  Modules/cPickle.c |  2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Modules/cPickle.c b/Modules/cPickle.c
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -3448,7 +3448,7 @@
      * to extend a BININT's sign bit to the full width.
      */
     if (x == 4 && l & (1L << 31))
-        l |= (~0L) << 32;
+        l |= (~0UL) << 32;
 #endif
     return l;
 }

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list