[Python-checkins] cpython (3.3): don't do pointer arithmetic with signed numbers

benjamin.peterson python-checkins at python.org
Sat Mar 15 03:47:59 CET 2014


http://hg.python.org/cpython/rev/d1b392141123
changeset:   89658:d1b392141123
branch:      3.3
parent:      89647:d7950e916f20
user:        Benjamin Peterson <benjamin at python.org>
date:        Fri Mar 14 21:47:23 2014 -0500
summary:
  don't do pointer arithmetic with signed numbers

files:
  Objects/longobject.c |  3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)


diff --git a/Objects/longobject.c b/Objects/longobject.c
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -36,7 +36,8 @@
 static PyObject *
 get_small_int(sdigit ival)
 {
-    PyObject *v = (PyObject*)(small_ints + ival + NSMALLNEGINTS);
+    assert(-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS);
+    PyObject *v = (PyObject *)&small_ints[ival + NSMALLNEGINTS];
     Py_INCREF(v);
 #ifdef COUNT_ALLOCS
     if (ival >= 0)

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


More information about the Python-checkins mailing list