]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43033: Fix the handling of PyObject_SetAttrString() in _zoneinfo.c (GH-24345)
authorZackery Spytz <zspytz@gmail.com>
Wed, 27 Jan 2021 08:16:20 +0000 (01:16 -0700)
committerGitHub <noreply@github.com>
Wed, 27 Jan 2021 08:16:20 +0000 (10:16 +0200)
Modules/_zoneinfo.c

index d1e09340d1df877a949cf8a69f2168697dc2593d..4a4cbdbee38d11d095df8ec58d0bb31e03e74339 100644 (file)
@@ -2525,7 +2525,11 @@ zoneinfo_init_subclass(PyTypeObject *cls, PyObject *args, PyObject **kwargs)
         return NULL;
     }
 
-    PyObject_SetAttrString((PyObject *)cls, "_weak_cache", weak_cache);
+    if (PyObject_SetAttrString((PyObject *)cls, "_weak_cache",
+                               weak_cache) < 0) {
+        Py_DECREF(weak_cache);
+        return NULL;
+    }
     Py_DECREF(weak_cache);
     Py_RETURN_NONE;
 }