]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-83004: Clean up refleak in _zoneinfo initialisation (GH-98842)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 6 Nov 2022 14:30:41 +0000 (06:30 -0800)
committerGitHub <noreply@github.com>
Sun, 6 Nov 2022 14:30:41 +0000 (06:30 -0800)
(cherry picked from commit 31f2f6568d89564cc1d686cd6b75ba5578aaa748)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Misc/NEWS.d/next/Library/2022-11-02-05-54-02.gh-issue-83004.0v8iyw.rst [new file with mode: 0644]
Modules/_zoneinfo.c

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 (file)
index 0000000..bd54d3e
--- /dev/null
@@ -0,0 +1 @@
+Clean up refleak on failed module initialisation in :mod:`_zoneinfo`
index 1535721b026d1f6943e0acc380dbdb921e2355d3..55975f4e269109d574322b96af681ff2d7678573 100644 (file)
@@ -2652,8 +2652,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");