From d56cbe57b8f57156420130c1a4b9868e743b0242 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 25 Jun 2004 22:17:39 +0000 Subject: [PATCH] Fix leak found by Eric Huss. --- Objects/typeobject.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index ee6e5d988d..115e1e66b5 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3954,7 +3954,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 -- 2.50.1