Skip to content

Commit 1e66e50

Browse files
committed
Don't evaluate macro argument twice
1 parent b7b9c6a commit 1e66e50

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Include/internal/pycore_stackref.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ PyStackRef_FromPyObjectImmortal(PyObject *obj)
528528
return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_IMMORTAL};
529529
}
530530

531+
/* WARNING: This macro evaluates its argument twice */
531532
#ifdef _WIN32
532533
#define PyStackRef_DUP(REF) \
533534
(PyStackRef_IsUncountedMortal(REF) ? (Py_INCREF_MORTAL(BITS_TO_PTR(REF)), (REF)) : (REF))
@@ -565,7 +566,8 @@ PyStackRef_MakeHeapSafe(_PyStackRef ref)
565566
#ifdef _WIN32
566567
#define PyStackRef_CLOSE(REF) \
567568
do { \
568-
if (PyStackRef_IsUncountedMortal(REF)) Py_DECREF_MORTAL(BITS_TO_PTR(REF)); \
569+
_PyStackRef _temp = (REF);
570+
if (PyStackRef_IsUncountedMortal(_temp)) Py_DECREF_MORTAL(BITS_TO_PTR(_temp)); \
569571
} while (0)
570572
#else
571573
static inline void

0 commit comments

Comments
 (0)