Skip to content

Commit bff5255

Browse files
bpo-36854: Fix reference counter in PyInit__testcapi() (GH-17338)
Increment properly Py_True/Py_False reference counter for _testcapi.WITH_PYMALLOC variable. (cherry picked from commit 84c36c1) Co-authored-by: Victor Stinner <[email protected]>
1 parent 91c15a5 commit bff5255

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Modules/_testcapimodule.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5444,11 +5444,14 @@ PyInit__testcapi(void)
54445444
PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type);
54455445

54465446
PyModule_AddIntConstant(m, "the_number_three", 3);
5447+
PyObject *v;
54475448
#ifdef WITH_PYMALLOC
5448-
PyModule_AddObject(m, "WITH_PYMALLOC", Py_True);
5449+
v = Py_True;
54495450
#else
5450-
PyModule_AddObject(m, "WITH_PYMALLOC", Py_False);
5451+
v = Py_False;
54515452
#endif
5453+
Py_INCREF(v);
5454+
PyModule_AddObject(m, "WITH_PYMALLOC", v);
54525455

54535456
TestError = PyErr_NewException("_testcapi.error", NULL, NULL);
54545457
Py_INCREF(TestError);

0 commit comments

Comments
 (0)