Skip to content

Commit e547f07

Browse files
committed
Fix null pointer deref
1 parent 63d9b90 commit e547f07

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

Include/cpython/tupleobject.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
3636
assert(0 <= index);
3737
assert(index < Py_SIZE(tuple));
3838
tuple->ob_item[index] = value;
39-
tuple->contains_mortal |= !_Py_IsImmortal(value);
39+
if (value != NULL) {
40+
tuple->contains_mortal |= !_Py_IsImmortal(value);
41+
}
4042
}
4143
#define PyTuple_SET_ITEM(op, index, value) \
4244
PyTuple_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value))

Objects/tupleobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ PyTuple_GetItem(PyObject *op, Py_ssize_t i)
111111
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
112112
return NULL;
113113
}
114-
return ((PyTupleObject *)op) -> ob_item[i];
114+
return ((PyTupleObject *)op)->ob_item[i];
115115
}
116116

117117
int

0 commit comments

Comments
 (0)