Skip to content

Commit a2ac8e7

Browse files
committed
Check for immortality in refcount accounting
1 parent 36ef3bf commit a2ac8e7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Include/refcount.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ static inline Py_ALWAYS_INLINE void Py_INCREF_MORTAL(PyObject *op)
249249
op->ob_refcnt++;
250250
_Py_INCREF_STAT_INC();
251251
#if defined(Py_REF_DEBUG) && !defined(Py_LIMITED_API)
252-
_Py_INCREF_IncRefTotal();
252+
if (!_Py_IsImmortal(op)) {
253+
_Py_INCREF_IncRefTotal();
254+
}
253255
#endif
254256
}
255257
#endif
@@ -391,7 +393,9 @@ static inline void Py_DECREF_MORTAL(const char *filename, int lineno, PyObject *
391393
}
392394
_Py_DECREF_STAT_INC();
393395
assert(!_Py_IsStaticImmortal(op));
394-
_Py_DECREF_DecRefTotal();
396+
if (!_Py_IsImmortal(op)) {
397+
_Py_DECREF_DecRefTotal();
398+
}
395399
if (--op->ob_refcnt == 0) {
396400
_Py_Dealloc(op);
397401
}
@@ -407,7 +411,9 @@ static inline void _Py_DECREF_MORTAL_SPECIALIZED(const char *filename, int linen
407411
}
408412
_Py_DECREF_STAT_INC();
409413
assert(!_Py_IsStaticImmortal(op));
410-
_Py_DECREF_DecRefTotal();
414+
if (!_Py_IsImmortal(op)) {
415+
_Py_DECREF_DecRefTotal();
416+
}
411417
if (--op->ob_refcnt == 0) {
412418
destruct(op);
413419
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy