From af065c34bc232993544317a3aa827a61e44a30ab Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 13 Jun 2008 15:36:43 +0000 Subject: 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. ........ --- Modules/_multiprocessing/multiprocessing.c | 18 ++++++++++++------ 1 file 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; } -- cgit v0.12