]> granicus.if.org Git - python/commitdiff
cast negative numbers to size_t before shifting them (#20929)
authorBenjamin Peterson <benjamin@python.org>
Sat, 15 Mar 2014 01:15:29 +0000 (20:15 -0500)
committerBenjamin Peterson <benjamin@python.org>
Sat, 15 Mar 2014 01:15:29 +0000 (20:15 -0500)
Include/objimpl.h
Misc/NEWS

index 9a27ec384f9fb0d0d18f9b9012103bd9bcade55a..3f21b70e0744ee73f5fadf02271c200dfee74d59 100644 (file)
@@ -265,7 +265,7 @@ extern PyGC_Head *_PyGC_generation0;
 #define _PyGCHead_REFS(g) ((g)->gc.gc_refs >> _PyGC_REFS_SHIFT)
 #define _PyGCHead_SET_REFS(g, v) do { \
     (g)->gc.gc_refs = ((g)->gc.gc_refs & ~_PyGC_REFS_MASK) \
-        | (v << _PyGC_REFS_SHIFT); \
+        | (((size_t)(v)) << _PyGC_REFS_SHIFT);             \
     } while (0)
 #define _PyGCHead_DECREF(g) ((g)->gc.gc_refs -= 1 << _PyGC_REFS_SHIFT)
 
index 91c669382cead6c9076f0468d361bc8468b6f687..dd5d7da83b8e64811af004d57fd27d6a68e79df3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -8,6 +8,8 @@ What's New in Python 3.4.1?
 Core and Builtins
 -----------------
 
+- Issue #20929: Add a type cast to avoid shifting a negative number.
+
 - Issue #20731: Properly position in source code files even if they
   are opened in text mode. Patch by Serhiy Storchaka.