diff Objects/unicodeobject.c @ 29641:4909aa64405f legacy-trunk

SF patch 703666: Several objects don't decref tmp on failure in subtype_new Submitted By: Christopher A. Craig Fillin some missing decrefs.
author Raymond Hettinger <python@rcn.com>
date Sat, 28 Jun 2003 20:04:25 +0000
parents 4d9017ef7b5f
children a4fead0e24f8
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Sat Jun 28 15:22:16 2003 +0000
+++ b/Objects/unicodeobject.c	Sat Jun 28 20:04:25 2003 +0000
@@ -6688,12 +6688,15 @@
 		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);