]> granicus.if.org Git - python/commitdiff
slot_tp_hash(): In the normal path, this leaked a reference to the
authorTim Peters <tim.peters@gmail.com>
Fri, 6 Dec 2002 23:38:02 +0000 (23:38 +0000)
committerTim Peters <tim.peters@gmail.com>
Fri, 6 Dec 2002 23:38:02 +0000 (23:38 +0000)
integer hash object returned by __hash__().  This accounts for some of
the "mystery leaks" in the sandbox datetime tests, but probably not
all of them.

Objects/typeobject.c

index 4cfbd49fc4d07b7dc9911d6de9718350c4e3af16..612944214ef74b205e9e24483ae963e9dbd1e76c 100644 (file)
@@ -3941,19 +3941,19 @@ slot_tp_str(PyObject *self)
 static long
 slot_tp_hash(PyObject *self)
 {
-       PyObject *func, *res;
+       PyObject *func;
        static PyObject *hash_str, *eq_str, *cmp_str;
-
        long h;
 
        func = lookup_method(self, "__hash__", &hash_str);
 
        if (func != NULL) {
-               res = PyEval_CallObject(func, NULL);
+               PyObject *res = PyEval_CallObject(func, NULL);
                Py_DECREF(func);
                if (res == NULL)
                        return -1;
                h = PyInt_AsLong(res);
+               Py_DECREF(res);
        }
        else {
                PyErr_Clear();