diff options
author | Georg Brandl <georg@python.org> | 2008-06-13 06:56:50 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-06-13 06:56:50 (GMT) |
commit | 6d53e7e69cb8c615e6ea3e1670b5e2c8735277a8 (patch) | |
tree | 3142c07e2fb40812931e50d253e41c7072a97a05 /Modules/_multiprocessing | |
parent | 04097a628213df725c43b62b7be934e0bff6fb16 (diff) | |
download | cpython-6d53e7e69cb8c615e6ea3e1670b5e2c8735277a8.zip cpython-6d53e7e69cb8c615e6ea3e1670b5e2c8735277a8.tar.gz cpython-6d53e7e69cb8c615e6ea3e1670b5e2c8735277a8.tar.bz2 |
#3095: don't leak values from Py_BuildValue.
Diffstat (limited to 'Modules/_multiprocessing')
-rw-r--r-- | Modules/_multiprocessing/multiprocessing.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c index 1050e1f..a38cd89 100644 --- a/Modules/_multiprocessing/multiprocessing.c +++ b/Modules/_multiprocessing/multiprocessing.c @@ -215,7 +215,7 @@ static PyMethodDef module_methods[] = { PyMODINIT_FUNC
init_multiprocessing(void)
{
- PyObject *module, *temp;
+ PyObject *module, *temp, *value;
/* Initialize module */
module = Py_InitModule("_multiprocessing", module_methods);
@@ -284,11 +284,12 @@ init_multiprocessing(void) temp = PyDict_New();
if (!temp)
return;
- if (PyModule_AddObject(module, "flags", temp) < 0)
- return;
-
-#define ADD_FLAG(name) \
- if (PyDict_SetItemString(temp, #name, Py_BuildValue("i", name)) < 0) return
+#define ADD_FLAG(name) \
+ value = Py_BuildValue("i", name); \
+ if (value == NULL) { Py_DECREF(temp); return; } \
+ if (PyDict_SetItemString(temp, #name, value) < 0) { \
+ Py_DECREF(temp); Py_DECREF(value); return; } \
+ Py_DECREF(value)
#ifdef HAVE_SEM_OPEN
ADD_FLAG(HAVE_SEM_OPEN);
@@ -305,4 +306,6 @@ init_multiprocessing(void) #ifdef HAVE_BROKEN_SEM_UNLINK
ADD_FLAG(HAVE_BROKEN_SEM_UNLINK);
#endif
+ if (PyModule_AddObject(module, "flags", temp) < 0)
+ return;
}
|