GH-104142: Fix _Py_RefcntAdd to respect immortality (GH-104143)

This commit is contained in:
Brandt Bucher 2023-05-04 17:00:07 -07:00 committed by GitHub
parent fa86a77589
commit ce871fdc3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 16 deletions

View file

@ -58,6 +58,9 @@ extern void _Py_DecRefTotal(PyInterpreterState *);
// Increment reference count by n
static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
{
if (_Py_IsImmortal(op)) {
return;
}
#ifdef Py_REF_DEBUG
_Py_AddRefTotal(_PyInterpreterState_GET(), n);
#endif