From: Sergey Miryanov Date: Fri, 27 Mar 2026 21:40:50 +0000 (+0500) Subject: [3.14] Fix possible memory leak in OrderedDict popitem (GH-145247) (#146537) X-Git-Tag: v3.14.4~53 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ed38c20dd34a40ee7c27c3655c17298404044b78;p=thirdparty%2FPython%2Fcpython.git [3.14] Fix possible memory leak in OrderedDict popitem (GH-145247) (#146537) --- diff --git a/Objects/odictobject.c b/Objects/odictobject.c index bdd37fae99c5..aee85eb72bcf 100644 --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -1168,8 +1168,10 @@ OrderedDict_popitem_impl(PyODictObject *self, int last) node = last ? _odict_LAST(self) : _odict_FIRST(self); key = Py_NewRef(_odictnode_KEY(node)); value = _odict_popkey_hash((PyObject *)self, key, NULL, _odictnode_HASH(node)); - if (value == NULL) + if (value == NULL) { + Py_DECREF(key); return NULL; + } item = PyTuple_Pack(2, key, value); Py_DECREF(key); Py_DECREF(value);