summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-06-25 22:17:39 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-06-25 22:17:39 (GMT)
commitd56cbe57b8f57156420130c1a4b9868e743b0242 (patch)
tree7d07af0f90749233f09cb716f2091c2c3ca23d8a
parent22021579a9266f537bed1fbbb9b5496c65362fa0 (diff)
downloadcpython-d56cbe57b8f57156420130c1a4b9868e743b0242.zip
cpython-d56cbe57b8f57156420130c1a4b9868e743b0242.tar.gz
cpython-d56cbe57b8f57156420130c1a4b9868e743b0242.tar.bz2
Fix leak found by Eric Huss.
-rw-r--r--Objects/typeobject.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index ee6e5d9..115e1e6 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