Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af065c3

Browse files
committed
Merged revisions 64223-64224 via svnmerge from
svn+ssh://[email protected]/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. ........
1 parent f38e0d0 commit af065c3

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

Modules/_multiprocessing/multiprocessing.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Extension module used by mutliprocessing package
2+
* Extension module used by multiprocessing package
33
*
44
* multiprocessing.c
55
*
@@ -228,7 +228,7 @@ static struct PyModuleDef multiprocessing_module = {
228228
PyMODINIT_FUNC
229229
PyInit__multiprocessing(void)
230230
{
231-
PyObject *module, *temp;
231+
PyObject *module, *temp, *value;
232232

233233
/* Initialize module */
234234
module = PyModule_Create(&multiprocessing_module);
@@ -297,11 +297,13 @@ PyInit__multiprocessing(void)
297297
temp = PyDict_New();
298298
if (!temp)
299299
return NULL;
300-
if (PyModule_AddObject(module, "flags", temp) < 0)
301-
return NULL;
302300

303-
#define ADD_FLAG(name) \
304-
if (PyDict_SetItemString(temp, #name, Py_BuildValue("i", name)) < 0) return NULL
301+
#define ADD_FLAG(name) \
302+
value = Py_BuildValue("i", name); \
303+
if (value == NULL) { Py_DECREF(temp); return NULL; } \
304+
if (PyDict_SetItemString(temp, #name, value) < 0) { \
305+
Py_DECREF(temp); Py_DECREF(value); return NULL; } \
306+
Py_DECREF(value)
305307

306308
#ifdef HAVE_SEM_OPEN
307309
ADD_FLAG(HAVE_SEM_OPEN);
@@ -318,5 +320,9 @@ PyInit__multiprocessing(void)
318320
#ifdef HAVE_BROKEN_SEM_UNLINK
319321
ADD_FLAG(HAVE_BROKEN_SEM_UNLINK);
320322
#endif
323+
324+
if (PyModule_AddObject(module, "flags", temp) < 0)
325+
return NULL;
326+
321327
return module;
322328
}

0 commit comments

Comments
 (0)