]> granicus.if.org Git - python/commitdiff
slot_sq_length(): squash a leak.
authorGuido van Rossum <guido@python.org>
Mon, 1 Oct 2001 16:42:49 +0000 (16:42 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 1 Oct 2001 16:42:49 +0000 (16:42 +0000)
Objects/typeobject.c

index 7a79bcb7c605dc4ed1388562786baab3fc0c8348..ec36bfdb6d43af361a39113b9647ea63a8595612 100644 (file)
@@ -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")