]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport from head.
authorTim Peters <tim.peters@gmail.com>
Sat, 7 Dec 2002 02:28:17 +0000 (02:28 +0000)
committerTim Peters <tim.peters@gmail.com>
Sat, 7 Dec 2002 02:28:17 +0000 (02:28 +0000)
slot_tp_hash():  In the normal path, this leaked a reference to the
integer hash object returned by __hash__().

Objects/typeobject.c

index db25705c24457320bcf42cbcfd75928fca6f5b5b..e8ba871872ff74931dc04354ea3adc49c25f14f9 100644 (file)
@@ -3278,19 +3278,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();