diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-05-30 09:53:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-30 09:53:46 (GMT) |
commit | fd6b913535d78d3bfec710075ac930474c1057ca (patch) | |
tree | 8a6349d157521e3b9e21e20f082b7f7d7c159261 /Modules | |
parent | 7f04a1546f2be67bfa53ddaa5769002d4d1691f2 (diff) | |
download | cpython-fd6b913535d78d3bfec710075ac930474c1057ca.zip cpython-fd6b913535d78d3bfec710075ac930474c1057ca.tar.gz cpython-fd6b913535d78d3bfec710075ac930474c1057ca.tar.bz2 |
[3.12] gh-102251: Fix reference leak in _testsinglephase initialization (GH-105082) (#105083)
Correctly decref 'initialized' in init_module()
(cherry picked from commit d14eb3433cf2a40a202471b815f0a935f2840ead)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testsinglephase.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_testsinglephase.c b/Modules/_testsinglephase.c index a161577..8e6973f 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; } |