]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-83004: Clean up refleak in _zoneinfo initialisation (#98842)
authorShantanu <12621235+hauntsaninja@users.noreply.github.com>
Sun, 6 Nov 2022 14:04:36 +0000 (06:04 -0800)
committerGitHub <noreply@github.com>
Sun, 6 Nov 2022 14:04:36 +0000 (06:04 -0800)
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 36b25bf3c0546995d8085c45c89176a6dcad4efe..9986b9111177ce06fa9db24254c3a8148dc3f672 100644 (file)
@@ -2657,8 +2657,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 */
     _tzpath_find_tzfile =