From: Zackery Spytz Date: Wed, 27 Jan 2021 08:16:20 +0000 (-0700) Subject: bpo-43033: Fix the handling of PyObject_SetAttrString() in _zoneinfo.c (GH-24345) X-Git-Tag: v3.10.0a5~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5327f370344a627f1578d8183d197feb286371c6;p=thirdparty%2FPython%2Fcpython.git bpo-43033: Fix the handling of PyObject_SetAttrString() in _zoneinfo.c (GH-24345) --- diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index d1e09340d1df..4a4cbdbee38d 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -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; }