diff --git a/Modules/_testsinglephase.c b/Modules/_testsinglephase.c index a16157702ae789..8e6973f0b052cc 100644 --- a/Modules/_testsinglephase.c +++ b/Modules/_testsinglephase.c @@ -140,7 +140,9 @@ init_module(PyObject *module, module_state *state) if (initialized == NULL) { return -1; } - if (PyModule_AddObjectRef(module, "_module_initialized", initialized) != 0) { + int rc = PyModule_AddObjectRef(module, "_module_initialized", initialized); + Py_DECREF(initialized); + if (rc < 0) { return -1; }