Commit 1a9ee946 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #27225: Fixed a reference leak in type_new when setting __new__ fails.

Original patch by Xiang Zhang.
parent fcbb2c48
......@@ -2430,7 +2430,11 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
Py_DECREF(type);
return NULL;
}
PyDict_SetItemString(dict, "__new__", tmp);
if (PyDict_SetItemString(dict, "__new__", tmp) < 0) {
Py_DECREF(tmp);
Py_DECREF(type);
return NULL;
}
Py_DECREF(tmp);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment