diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-17 20:01:37 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-17 20:01:37 (GMT) |
commit | 5967bf49285f1d4c086d0d97db64c07e79b482d2 (patch) | |
tree | 6b8c5abe89ead86002a486f61178f6dc398812c9 | |
parent | e901d1fbdff989c3d4b47eb46b0eb1ae6e46b71c (diff) | |
download | cpython-5967bf49285f1d4c086d0d97db64c07e79b482d2.zip cpython-5967bf49285f1d4c086d0d97db64c07e79b482d2.tar.gz cpython-5967bf49285f1d4c086d0d97db64c07e79b482d2.tar.bz2 |
Issue #18408: Fix PyType_Ready(), handle _PyDict_SetItemId() failure
-rw-r--r-- | Objects/typeobject.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index f311af8..c970ada 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4256,11 +4256,15 @@ PyType_Ready(PyTypeObject *type) PyObject *doc = PyUnicode_FromString(type->tp_doc); if (doc == NULL) goto error; - _PyDict_SetItemId(type->tp_dict, &PyId___doc__, doc); + if (_PyDict_SetItemId(type->tp_dict, &PyId___doc__, doc) < 0) { + Py_DECREF(doc); + goto error; + } Py_DECREF(doc); } else { - _PyDict_SetItemId(type->tp_dict, - &PyId___doc__, Py_None); + if (_PyDict_SetItemId(type->tp_dict, + &PyId___doc__, Py_None) < 0) + goto error; } } |