diff Objects/stringobject.c @ 19632:20fb7591f885 legacy-trunk

Fix a memory leak in str_subtype_new(). (All the other xxx_subtype_new() functions are OK, but I goofed up in this one. :-( )
author Guido van Rossum <guido@python.org>
date Fri, 31 Aug 2001 16:11:15 +0000
parents 85765e61deb0
children 662e22f99639
line wrap: on
line diff
--- a/Objects/stringobject.c	Fri Aug 31 04:35:14 2001 +0000
+++ b/Objects/stringobject.c	Fri Aug 31 16:11:15 2001 +0000
@@ -2713,9 +2713,9 @@
 		return NULL;
 	assert(PyString_Check(tmp));
 	new = type->tp_alloc(type, n = PyString_GET_SIZE(tmp));
-	if (new == NULL)
-		return NULL;
-	memcpy(PyString_AS_STRING(new), PyString_AS_STRING(tmp), n+1);
+	if (new != NULL)
+		memcpy(PyString_AS_STRING(new), PyString_AS_STRING(tmp), n+1);
+	Py_DECREF(tmp);
 	return new;
 }