mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
SF patch 703666: Several objects don't decref tmp on failure in subtype_new
Submitted By: Christopher A. Craig Fillin some missing decrefs.
This commit is contained in:
parent
6891cd3aa3
commit
f466793fcc
4 changed files with 13 additions and 4 deletions
|
@ -6688,12 +6688,15 @@ unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
assert(PyUnicode_Check(tmp));
|
||||
pnew = (PyUnicodeObject *) type->tp_alloc(type, n = tmp->length);
|
||||
if (pnew == NULL)
|
||||
if (pnew == NULL) {
|
||||
Py_DECREF(tmp);
|
||||
return NULL;
|
||||
}
|
||||
pnew->str = PyMem_NEW(Py_UNICODE, n+1);
|
||||
if (pnew->str == NULL) {
|
||||
_Py_ForgetReference((PyObject *)pnew);
|
||||
PyObject_Del(pnew);
|
||||
Py_DECREF(tmp);
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
Py_UNICODE_COPY(pnew->str, tmp->str, n+1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue