From 041c38a790cb9ce14742765e3314d90a7c601809 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 14 Mar 2014 21:47:23 -0500 Subject: [PATCH] don't do pointer arithmetic with signed numbers --- Objects/longobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) -- 2.40.0