summaryrefslogtreecommitdiff
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-06-28 20:04:25 +0000
committerRaymond Hettinger <python@rcn.com>2003-06-28 20:04:25 +0000
commitf466793fcc6e2234f4843bd6a04625f1fac96132 (patch)
tree63ffd3139c3298e98551826ab9b7e41d4be9d536 /Objects/unicodeobject.c
parent6891cd3aa37ac3d27de5563849ef848eed1fe411 (diff)
downloadcpython-git-f466793fcc6e2234f4843bd6a04625f1fac96132.tar.gz
SF patch 703666: Several objects don't decref tmp on failure in subtype_new
Submitted By: Christopher A. Craig Fillin some missing decrefs.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 94c67c84df..af427dd118 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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);