]> 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:20:33 +0000 (22:20 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 25 Jun 2004 22:20:33 +0000 (22:20 +0000)
Objects/typeobject.c

index 5898df24c8634944491fb528d7656eac8f56b885..16cdbe8fa5e8238e889792c028abb322796702b8 100644 (file)
@@ -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