From: Raymond Hettinger Date: Tue, 16 Sep 2003 07:13:56 +0000 (+0000) Subject: Fix leak in classobject.c. The leak surfaced on the error exit when X-Git-Tag: v2.3.1~47 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bd40b912386242cd9b61eb81ac9ae1be59329057;p=thirdparty%2FPython%2Fcpython.git 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. --- 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; }