diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-06 06:38:26 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-06 06:38:26 -0800 |
commit | 70006d6a5ff4492f02625ac995dba5f58940a0ea (patch) | |
tree | 01ad3b76e7bb16c0562b0045a722244b6856c607 | |
parent | 92cc215518669aefb711e46977c8843a3a6dc751 (diff) | |
download | cpython-git-70006d6a5ff4492f02625ac995dba5f58940a0ea.tar.gz |
gh-83004: Clean up refleak in _zoneinfo initialisation (GH-98842)
(cherry picked from commit 31f2f6568d89564cc1d686cd6b75ba5578aaa748)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
-rw-r--r-- | Misc/NEWS.d/next/Library/2022-11-02-05-54-02.gh-issue-83004.0v8iyw.rst | 1 | ||||
-rw-r--r-- | Modules/_zoneinfo.c | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Library/2022-11-02-05-54-02.gh-issue-83004.0v8iyw.rst b/Misc/NEWS.d/next/Library/2022-11-02-05-54-02.gh-issue-83004.0v8iyw.rst new file mode 100644 index 0000000000..bd54d3eae8 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-11-02-05-54-02.gh-issue-83004.0v8iyw.rst @@ -0,0 +1 @@ +Clean up refleak on failed module initialisation in :mod:`_zoneinfo` diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index 0388d27ce1..836d1cfd60 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -2648,8 +2648,9 @@ zoneinfomodule_exec(PyObject *m) goto error; } - Py_INCREF(&PyZoneInfo_ZoneInfoType); - PyModule_AddObject(m, "ZoneInfo", (PyObject *)&PyZoneInfo_ZoneInfoType); + if (PyModule_AddObjectRef(m, "ZoneInfo", (PyObject *)&PyZoneInfo_ZoneInfoType) < 0) { + goto error; + } /* Populate imports */ PyObject *_tzpath_module = PyImport_ImportModule("zoneinfo._tzpath"); |