Skip to content

Commit d14eb34

Browse files
gh-102251: Fix reference leak in _testsinglephase initialization (#105082)
Correctly decref 'initialized' in init_module() Co-authored-by: Erlend E. Aasland <[email protected]>
1 parent 219f01b commit d14eb34

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Modules/_testsinglephase.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ init_module(PyObject *module, module_state *state)
140140
if (initialized == NULL) {
141141
return -1;
142142
}
143-
if (PyModule_AddObjectRef(module, "_module_initialized", initialized) != 0) {
143+
int rc = PyModule_AddObjectRef(module, "_module_initialized", initialized);
144+
Py_DECREF(initialized);
145+
if (rc < 0) {
144146
return -1;
145147
}
146148

0 commit comments

Comments
 (0)