#3095: don't leak values from Py_BuildValue.
This commit is contained in:
parent
04097a6282
commit
6d53e7e69c
|
@ -215,7 +215,7 @@ static PyMethodDef module_methods[] = {
|
||||||
PyMODINIT_FUNC
|
PyMODINIT_FUNC
|
||||||
init_multiprocessing(void)
|
init_multiprocessing(void)
|
||||||
{
|
{
|
||||||
PyObject *module, *temp;
|
PyObject *module, *temp, *value;
|
||||||
|
|
||||||
/* Initialize module */
|
/* Initialize module */
|
||||||
module = Py_InitModule("_multiprocessing", module_methods);
|
module = Py_InitModule("_multiprocessing", module_methods);
|
||||||
|
@ -284,11 +284,12 @@ init_multiprocessing(void)
|
||||||
temp = PyDict_New();
|
temp = PyDict_New();
|
||||||
if (!temp)
|
if (!temp)
|
||||||
return;
|
return;
|
||||||
if (PyModule_AddObject(module, "flags", temp) < 0)
|
#define ADD_FLAG(name) \
|
||||||
return;
|
value = Py_BuildValue("i", name); \
|
||||||
|
if (value == NULL) { Py_DECREF(temp); return; } \
|
||||||
#define ADD_FLAG(name) \
|
if (PyDict_SetItemString(temp, #name, value) < 0) { \
|
||||||
if (PyDict_SetItemString(temp, #name, Py_BuildValue("i", name)) < 0) return
|
Py_DECREF(temp); Py_DECREF(value); return; } \
|
||||||
|
Py_DECREF(value)
|
||||||
|
|
||||||
#ifdef HAVE_SEM_OPEN
|
#ifdef HAVE_SEM_OPEN
|
||||||
ADD_FLAG(HAVE_SEM_OPEN);
|
ADD_FLAG(HAVE_SEM_OPEN);
|
||||||
|
@ -305,4 +306,6 @@ init_multiprocessing(void)
|
||||||
#ifdef HAVE_BROKEN_SEM_UNLINK
|
#ifdef HAVE_BROKEN_SEM_UNLINK
|
||||||
ADD_FLAG(HAVE_BROKEN_SEM_UNLINK);
|
ADD_FLAG(HAVE_BROKEN_SEM_UNLINK);
|
||||||
#endif
|
#endif
|
||||||
|
if (PyModule_AddObject(module, "flags", temp) < 0)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue