]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix leak found by Eric Huss.
authorRaymond Hettinger <python@rcn.com>
Fri, 25 Jun 2004 22:17:39 +0000 (22:17 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 25 Jun 2004 22:17:39 +0000 (22:17 +0000)
Objects/typeobject.c

index ee6e5d988d36a18dd79518a11a91e13d348fe1b5..115e1e66b58eaeb679cbf05938846b603ce0358f 100644 (file)
@@ -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