summaryrefslogtreecommitdiff
path: root/Python/modsupport.c
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-08-04 03:11:25 +0000
committerFred Drake <fdrake@acm.org>2001-08-04 03:11:25 +0000
commit0d6e1bbd87b9f116b869e198509e158e3246f093 (patch)
tree3e27559611623aa230ecd7c63d93733443b6952d /Python/modsupport.c
parent22fe902f273968db0fffef72f5f87f48a4ba50a3 (diff)
downloadcpython-0d6e1bbd87b9f116b869e198509e158e3246f093.tar.gz
Plug a memory leak in Py_InitModule4(): when PyDict_SetItemString() failed,
the object being inserted was not being DECREFed. This closes SF bug #444486.
Diffstat (limited to 'Python/modsupport.c')
-rw-r--r--Python/modsupport.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index eb0818cc95..8fad54a323 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -60,14 +60,18 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc,
v = PyCFunction_New(ml, passthrough);
if (v == NULL)
return NULL;
- if (PyDict_SetItemString(d, ml->ml_name, v) != 0)
+ if (PyDict_SetItemString(d, ml->ml_name, v) != 0) {
+ Py_DECREF(v);
return NULL;
+ }
Py_DECREF(v);
}
if (doc != NULL) {
v = PyString_FromString(doc);
- if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0)
+ if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) {
+ Py_DECREF(v);
return NULL;
+ }
Py_DECREF(v);
}
return m;