From: Benjamin Peterson Date: Sat, 15 Mar 2014 02:47:23 +0000 (-0500) Subject: don't do pointer arithmetic with signed numbers X-Git-Tag: v3.4.1rc1~233^2~15^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=041c38a790cb9ce14742765e3314d90a7c601809;p=python don't do pointer arithmetic with signed numbers --- diff --git a/Objects/longobject.c b/Objects/longobject.c index 4ae22ef31b..e2d95ae51f 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -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)