summaryrefslogtreecommitdiffstats
path: root/Modules/_multiprocessing
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-06-13 15:36:43 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-06-13 15:36:43 (GMT)
commitaf065c34bc232993544317a3aa827a61e44a30ab (patch)
treee622f6d9b87a270e84711070b7afa29d08bd6c77 /Modules/_multiprocessing
parentf38e0d0c8ced2dd009d9afccc444a42b729dc009 (diff)
downloadcpython-af065c34bc232993544317a3aa827a61e44a30ab.zip
cpython-af065c34bc232993544317a3aa827a61e44a30ab.tar.gz
cpython-af065c34bc232993544317a3aa827a61e44a30ab.tar.bz2
Merged revisions 64223-64224 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r64223 | georg.brandl | 2008-06-13 01:56:50 -0500 (Fri, 13 Jun 2008) | 2 lines #3095: don't leak values from Py_BuildValue. ........ r64224 | georg.brandl | 2008-06-13 02:08:48 -0500 (Fri, 13 Jun 2008) | 2 lines Typo. ........
Diffstat (limited to 'Modules/_multiprocessing')
-rw-r--r--Modules/_multiprocessing/multiprocessing.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c
index 19d12ae..9e64635 100644
--- a/Modules/_multiprocessing/multiprocessing.c
+++ b/Modules/_multiprocessing/multiprocessing.c
@@ -1,5 +1,5 @@
/*
- * Extension module used by mutliprocessing package
+ * Extension module used by multiprocessing package
*
* multiprocessing.c
*
@@ -228,7 +228,7 @@ static struct PyModuleDef multiprocessing_module = {
PyMODINIT_FUNC
PyInit__multiprocessing(void)
{
- PyObject *module, *temp;
+ PyObject *module, *temp, *value;
/* Initialize module */
module = PyModule_Create(&multiprocessing_module);
@@ -297,11 +297,13 @@ PyInit__multiprocessing(void)
temp = PyDict_New();
if (!temp)
return NULL;
- if (PyModule_AddObject(module, "flags", temp) < 0)
- return NULL;
-#define ADD_FLAG(name) \
- if (PyDict_SetItemString(temp, #name, Py_BuildValue("i", name)) < 0) return NULL
+#define ADD_FLAG(name) \
+ value = Py_BuildValue("i", name); \
+ if (value == NULL) { Py_DECREF(temp); return NULL; } \
+ if (PyDict_SetItemString(temp, #name, value) < 0) { \
+ Py_DECREF(temp); Py_DECREF(value); return NULL; } \
+ Py_DECREF(value)
#ifdef HAVE_SEM_OPEN
ADD_FLAG(HAVE_SEM_OPEN);
@@ -318,5 +320,9 @@ PyInit__multiprocessing(void)
#ifdef HAVE_BROKEN_SEM_UNLINK
ADD_FLAG(HAVE_BROKEN_SEM_UNLINK);
#endif
+
+ if (PyModule_AddObject(module, "flags", temp) < 0)
+ return NULL;
+
return module;
}