Skip to content

Commit

Permalink
gh-102251: Fix reference leak in _testsinglephase initialization (#10…
Browse files Browse the repository at this point in the history
…5082)

Correctly decref 'initialized' in init_module()

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
  • Loading branch information
sunmy2019 and erlend-aasland authored May 30, 2023
1 parent 219f01b commit d14eb34
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Modules/_testsinglephase.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d14eb34

Please sign in to comment.