summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-31 16:11:15 (GMT)
committerGuido van Rossum <guido@python.org>2001-08-31 16:11:15 (GMT)
commit29d55a38ce15062bcabf78a52faa828002b5bbd4 (patch)
tree1eb4e7793674ebc3e5048006e2d6b99e760d2b7e /Objects/stringobject.c
parentbfa47b072542ea17ce478572d202b8ef60120737 (diff)
downloadcpython-29d55a38ce15062bcabf78a52faa828002b5bbd4.zip
cpython-29d55a38ce15062bcabf78a52faa828002b5bbd4.tar.gz
cpython-29d55a38ce15062bcabf78a52faa828002b5bbd4.tar.bz2
Fix a memory leak in str_subtype_new(). (All the other
xxx_subtype_new() functions are OK, but I goofed up in this one. :-( )
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r--Objects/stringobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 7675f7e..4c28500 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -2713,9 +2713,9 @@ str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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;
}