Mercurial > cpython-lru_cache-weakref
diff Objects/typeobject.c @ 32406:d99b5bed0078 2.3
Fix leak found by Eric Huss.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 25 Jun 2004 22:20:33 +0000 |
| parents | b054cff7bb86 |
| children | a6c80170fc53 |
line wrap: on
line diff
--- a/Objects/typeobject.c Sun Jun 20 21:03:36 2004 +0000 +++ b/Objects/typeobject.c Fri Jun 25 22:20:33 2004 +0000 @@ -3913,7 +3913,12 @@ 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
