changeset: 89657:e68f156ea0e6 user: Benjamin Peterson date: Fri Mar 14 20:15:29 2014 -0500 files: Include/objimpl.h Misc/NEWS description: cast negative numbers to size_t before shifting them (#20929) diff -r 63d2d0c15b37 -r e68f156ea0e6 Include/objimpl.h --- a/Include/objimpl.h Fri Mar 14 23:13:00 2014 +0000 +++ b/Include/objimpl.h Fri Mar 14 20:15:29 2014 -0500 @@ -265,7 +265,7 @@ #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) diff -r 63d2d0c15b37 -r e68f156ea0e6 Misc/NEWS --- a/Misc/NEWS Fri Mar 14 23:13:00 2014 +0000 +++ b/Misc/NEWS Fri Mar 14 20:15:29 2014 -0500 @@ -8,6 +8,8 @@ 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.