From bd40b912386242cd9b61eb81ac9ae1be59329057 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 16 Sep 2003 07:13:56 +0000 Subject: [PATCH] Fix leak in classobject.c. The leak surfaced on the error exit when hashing a class that does not define __hash__ but does define a comparison. --- Misc/NEWS | 3 +++ Objects/classobject.c | 1 + 2 files changed, 4 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 7912ae4ab5bb..d7b47c7016ef 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ What's New in Python 2.3.1? Core and builtins ----------------- +- Fixed a leak in class objects defining a comparison but not a hash + function. + - Bug #789402, fixed memory leak when opening a file object. - Fixed a leak when new code objects are instantiated. diff --git a/Objects/classobject.c b/Objects/classobject.c index 9375e0737075..0df249de6cea 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -953,6 +953,7 @@ instance_hash(PyInstanceObject *inst) return _Py_HashPointer(inst); } } + Py_XDECREF(func); PyErr_SetString(PyExc_TypeError, "unhashable instance"); return -1; } -- 2.47.3