]> granicus.if.org Git - python/commitdiff
don't do pointer arithmetic with signed numbers
authorBenjamin Peterson <benjamin@python.org>
Sat, 15 Mar 2014 02:47:23 +0000 (21:47 -0500)
committerBenjamin Peterson <benjamin@python.org>
Sat, 15 Mar 2014 02:47:23 +0000 (21:47 -0500)
Objects/longobject.c

index 4ae22ef31b6eb61f19471164033b6bc48ee81339..e2d95ae51fd9f1546fdda09ecf90ee222dc35d36 100644 (file)
@@ -36,7 +36,8 @@ Py_ssize_t quick_int_allocs, quick_neg_int_allocs;
 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)