From: Raymond Hettinger Date: Fri, 25 Jun 2004 22:20:33 +0000 (+0000) Subject: Fix leak found by Eric Huss. X-Git-Tag: v2.3.5c1~199 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5c2ab599c00462dc13cccaf344bf205991262ff4;p=thirdparty%2FPython%2Fcpython.git Fix leak found by Eric Huss. --- diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 5898df24c863..16cdbe8fa5e8 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3913,7 +3913,12 @@ add_tp_new_wrapper(PyTypeObject *type) func = PyCFunction_New(tp_new_methoddef, (PyObject *)type); if (func == NULL) return -1; - return PyDict_SetItemString(type->tp_dict, "__new__", func); + if(PyDict_SetItemString(type->tp_dict, "__new__", func)) { + Py_DECREF(func); + return -1; + } + Py_DECREF(func); + return 0; } /* Slot wrappers that call the corresponding __foo__ slot. See comments