diff options
author | Fred Drake <fdrake@acm.org> | 2001-08-04 03:11:25 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-08-04 03:11:25 (GMT) |
commit | 289898cdbb1d4526ce45e600ed2843a14d1feb0d (patch) | |
tree | 66a0133f6d889e3c4dba649823f1cad7b40fc749 | |
parent | 53765753c4b1ede0fd25eadde52e235c62b1c8b7 (diff) | |
download | cpython-289898cdbb1d4526ce45e600ed2843a14d1feb0d.zip cpython-289898cdbb1d4526ce45e600ed2843a14d1feb0d.tar.gz cpython-289898cdbb1d4526ce45e600ed2843a14d1feb0d.tar.bz2 |
Plug a memory leak in Py_InitModule4(): when PyDict_SetItemString() failed,
the object being inserted was not being DECREFed.
This closes SF bug #444486.
-rw-r--r-- | Python/modsupport.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c index eb0818c..8fad54a 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; |