Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29d55a3

Browse files
committed
Fix a memory leak in str_subtype_new(). (All the other
xxx_subtype_new() functions are OK, but I goofed up in this one. :-( )
1 parent bfa47b0 commit 29d55a3

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Objects/stringobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,9 +2713,9 @@ str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
27132713
return NULL;
27142714
assert(PyString_Check(tmp));
27152715
new = type->tp_alloc(type, n = PyString_GET_SIZE(tmp));
2716-
if (new == NULL)
2717-
return NULL;
2718-
memcpy(PyString_AS_STRING(new), PyString_AS_STRING(tmp), n+1);
2716+
if (new != NULL)
2717+
memcpy(PyString_AS_STRING(new), PyString_AS_STRING(tmp), n+1);
2718+
Py_DECREF(tmp);
27192719
return new;
27202720
}
27212721

0 commit comments

Comments
 (0)