From: Guido van Rossum Date: Mon, 1 Oct 2001 16:42:49 +0000 (+0000) Subject: slot_sq_length(): squash a leak. X-Git-Tag: v2.2.1c1~1517 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=261116234504e5a250fcb3df704b3438ebc46531;p=python slot_sq_length(): squash a leak. --- diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 7a79bcb7c6..ec36bfdb6d 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2729,10 +2729,13 @@ slot_sq_length(PyObject *self) { static PyObject *len_str; PyObject *res = call_method(self, "__len__", &len_str, "()"); + int len; if (res == NULL) return -1; - return (int)PyInt_AsLong(res); + len = (int)PyInt_AsLong(res); + Py_DECREF(res); + return len; } SLOT1(slot_sq_concat, "__add__", PyObject *, "O")