mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
updated for version 7.3.1162
Problem: Python: Memory leaks Solution: Add more Py_DECREF(). (ZyX)
This commit is contained in:
@@ -5354,6 +5354,7 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyObject *other_module;
|
PyObject *other_module;
|
||||||
|
PyObject *attr;
|
||||||
|
|
||||||
for (i = 0; i < (int)(sizeof(numeric_constants)
|
for (i = 0; i < (int)(sizeof(numeric_constants)
|
||||||
/ sizeof(struct numeric_constant));
|
/ sizeof(struct numeric_constant));
|
||||||
@@ -5392,14 +5393,26 @@ populate_module(PyObject *m, object_adder add_object, attr_getter get_attr)
|
|||||||
if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir")))
|
if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir")))
|
||||||
return -1;
|
return -1;
|
||||||
ADD_OBJECT(m, "_chdir", py_chdir);
|
ADD_OBJECT(m, "_chdir", py_chdir);
|
||||||
if (PyObject_SetAttrString(other_module, "chdir", get_attr(m, "chdir")))
|
if (!(attr = get_attr(m, "chdir")))
|
||||||
return -1;
|
return -1;
|
||||||
|
if (PyObject_SetAttrString(other_module, "chdir", attr))
|
||||||
|
{
|
||||||
|
Py_DECREF(attr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Py_DECREF(attr);
|
||||||
|
|
||||||
if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir")))
|
if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir")))
|
||||||
{
|
{
|
||||||
ADD_OBJECT(m, "_fchdir", py_fchdir);
|
ADD_OBJECT(m, "_fchdir", py_fchdir);
|
||||||
if (PyObject_SetAttrString(other_module,"fchdir",get_attr(m,"fchdir")))
|
if (!(attr = get_attr(m, "fchdir")))
|
||||||
return -1;
|
return -1;
|
||||||
|
if (PyObject_SetAttrString(other_module, "fchdir", attr))
|
||||||
|
{
|
||||||
|
Py_DECREF(attr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Py_DECREF(attr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
@@ -210,6 +210,7 @@ struct PyMethodDef { Py_ssize_t a; };
|
|||||||
# define PyMapping_Check dll_PyMapping_Check
|
# define PyMapping_Check dll_PyMapping_Check
|
||||||
# define PyIter_Next dll_PyIter_Next
|
# define PyIter_Next dll_PyIter_Next
|
||||||
# define PyModule_GetDict dll_PyModule_GetDict
|
# define PyModule_GetDict dll_PyModule_GetDict
|
||||||
|
# define PyModule_AddObject dll_PyModule_AddObject
|
||||||
# define PyRun_SimpleString dll_PyRun_SimpleString
|
# define PyRun_SimpleString dll_PyRun_SimpleString
|
||||||
# define PyRun_String dll_PyRun_String
|
# define PyRun_String dll_PyRun_String
|
||||||
# define PyObject_GetAttrString dll_PyObject_GetAttrString
|
# define PyObject_GetAttrString dll_PyObject_GetAttrString
|
||||||
@@ -344,6 +345,7 @@ static PyObject* (*dll_PyObject_CallMethod)(PyObject *, char *, PyObject *);
|
|||||||
static int (*dll_PyMapping_Check)(PyObject *);
|
static int (*dll_PyMapping_Check)(PyObject *);
|
||||||
static PyObject* (*dll_PyIter_Next)(PyObject *);
|
static PyObject* (*dll_PyIter_Next)(PyObject *);
|
||||||
static PyObject*(*dll_PyModule_GetDict)(PyObject *);
|
static PyObject*(*dll_PyModule_GetDict)(PyObject *);
|
||||||
|
static int(*dll_PyModule_AddObject)(PyObject *, const char *, PyObject *);
|
||||||
static int(*dll_PyRun_SimpleString)(char *);
|
static int(*dll_PyRun_SimpleString)(char *);
|
||||||
static PyObject *(*dll_PyRun_String)(char *, int, PyObject *, PyObject *);
|
static PyObject *(*dll_PyRun_String)(char *, int, PyObject *, PyObject *);
|
||||||
static PyObject* (*dll_PyObject_GetAttrString)(PyObject *, const char *);
|
static PyObject* (*dll_PyObject_GetAttrString)(PyObject *, const char *);
|
||||||
@@ -509,6 +511,7 @@ static struct
|
|||||||
{"PyMapping_Check", (PYTHON_PROC*)&dll_PyMapping_Check},
|
{"PyMapping_Check", (PYTHON_PROC*)&dll_PyMapping_Check},
|
||||||
{"PyIter_Next", (PYTHON_PROC*)&dll_PyIter_Next},
|
{"PyIter_Next", (PYTHON_PROC*)&dll_PyIter_Next},
|
||||||
{"PyModule_GetDict", (PYTHON_PROC*)&dll_PyModule_GetDict},
|
{"PyModule_GetDict", (PYTHON_PROC*)&dll_PyModule_GetDict},
|
||||||
|
{"PyModule_AddObject", (PYTHON_PROC*)&dll_PyModule_AddObject},
|
||||||
{"PyRun_SimpleString", (PYTHON_PROC*)&dll_PyRun_SimpleString},
|
{"PyRun_SimpleString", (PYTHON_PROC*)&dll_PyRun_SimpleString},
|
||||||
{"PyRun_String", (PYTHON_PROC*)&dll_PyRun_String},
|
{"PyRun_String", (PYTHON_PROC*)&dll_PyRun_String},
|
||||||
{"PyObject_GetAttrString", (PYTHON_PROC*)&dll_PyObject_GetAttrString},
|
{"PyObject_GetAttrString", (PYTHON_PROC*)&dll_PyObject_GetAttrString},
|
||||||
@@ -1356,20 +1359,10 @@ python_tabpage_free(tabpage_T *tab)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
|
||||||
add_object(PyObject *dict, const char *name, PyObject *object)
|
|
||||||
{
|
|
||||||
if (PyDict_SetItemString(dict, (char *) name, object))
|
|
||||||
return -1;
|
|
||||||
Py_DECREF(object);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
PythonMod_Init(void)
|
PythonMod_Init(void)
|
||||||
{
|
{
|
||||||
PyObject *mod;
|
PyObject *mod;
|
||||||
PyObject *dict;
|
|
||||||
|
|
||||||
/* The special value is removed from sys.path in Python_Init(). */
|
/* The special value is removed from sys.path in Python_Init(). */
|
||||||
static char *(argv[2]) = {"/must>not&exist/foo", NULL};
|
static char *(argv[2]) = {"/must>not&exist/foo", NULL};
|
||||||
@@ -1382,9 +1375,8 @@ PythonMod_Init(void)
|
|||||||
|
|
||||||
mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL,
|
mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL,
|
||||||
PYTHON_API_VERSION);
|
PYTHON_API_VERSION);
|
||||||
dict = PyModule_GetDict(mod);
|
|
||||||
|
|
||||||
return populate_module(dict, add_object, PyDict_GetItemString);
|
return populate_module(mod, PyModule_AddObject, PyObject_GetAttrString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1162,
|
||||||
/**/
|
/**/
|
||||||
1161,
|
1161,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user