Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 041c38a

Browse files
committed
don't do pointer arithmetic with signed numbers
1 parent e5cb836 commit 041c38a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Objects/longobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ Py_ssize_t quick_int_allocs, quick_neg_int_allocs;
3636
static PyObject *
3737
get_small_int(sdigit ival)
3838
{
39-
PyObject *v = (PyObject*)(small_ints + ival + NSMALLNEGINTS);
39+
assert(-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS);
40+
PyObject *v = (PyObject *)&small_ints[ival + NSMALLNEGINTS];
4041
Py_INCREF(v);
4142
#ifdef COUNT_ALLOCS
4243
if (ival >= 0)

0 commit comments

Comments
 (0)