0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

updated for version 7.3.1002

Problem:    Valgrind errors for Python interface.
Solution:   Fix memory leaks when running tests. (ZyX)
This commit is contained in:
Bram Moolenaar
2013-05-21 22:13:41 +02:00
parent 673af4d304
commit 0b9aecc3a5
2 changed files with 21 additions and 10 deletions

View File

@@ -866,6 +866,7 @@ DictionaryAssItem(DictionaryObject *self, PyObject *keyObject, PyObject *valObje
DICTKEY_UNREF DICTKEY_UNREF
copy_tv(&tv, &di->di_tv); copy_tv(&tv, &di->di_tv);
clear_tv(&tv);
return 0; return 0;
} }
@@ -1129,6 +1130,7 @@ ListAssItem(ListObject *self, Py_ssize_t index, PyObject *obj)
{ {
if (list_append_tv(l, &tv) == FAIL) if (list_append_tv(l, &tv) == FAIL)
{ {
clear_tv(&tv);
PyErr_SetVim(_("Failed to add item to list")); PyErr_SetVim(_("Failed to add item to list"));
return -1; return -1;
} }
@@ -1138,6 +1140,7 @@ ListAssItem(ListObject *self, Py_ssize_t index, PyObject *obj)
li = list_find(l, (long) index); li = list_find(l, (long) index);
clear_tv(&li->li_tv); clear_tv(&li->li_tv);
copy_tv(&tv, &li->li_tv); copy_tv(&tv, &li->li_tv);
clear_tv(&tv);
} }
return 0; return 0;
} }
@@ -1204,9 +1207,11 @@ ListAssSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last, PyObject *obj)
return -1; return -1;
if (list_insert_tv(l, &v, li) == FAIL) if (list_insert_tv(l, &v, li) == FAIL)
{ {
clear_tv(&v);
PyErr_SetVim(_("internal error: failed to add item to list")); PyErr_SetVim(_("internal error: failed to add item to list"));
return -1; return -1;
} }
clear_tv(&v);
} }
return 0; return 0;
} }
@@ -1346,7 +1351,10 @@ FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs)
return NULL; return NULL;
} }
if (ConvertFromPyObject(selfdictObject, &selfdicttv) == -1) if (ConvertFromPyObject(selfdictObject, &selfdicttv) == -1)
{
clear_tv(&args);
return NULL; return NULL;
}
selfdict = selfdicttv.vval.v_dict; selfdict = selfdicttv.vval.v_dict;
} }
} }
@@ -1370,13 +1378,10 @@ FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs)
else else
result = ConvertToPyObject(&rettv); result = ConvertToPyObject(&rettv);
/* FIXME Check what should really be cleared. */
clear_tv(&args); clear_tv(&args);
clear_tv(&rettv); clear_tv(&rettv);
/* if (selfdict != NULL)
* if (selfdict!=NULL) clear_tv(&selfdicttv);
* clear_tv(selfdicttv);
*/
return result; return result;
} }
@@ -1482,7 +1487,7 @@ OptionsItem(OptionsObject *self, PyObject *keyObject)
} }
else if (flags & SOPT_BOOL) else if (flags & SOPT_BOOL)
{ {
PyObject *r; PyObject *r;
r = numval ? Py_True : Py_False; r = numval ? Py_True : Py_False;
Py_INCREF(r); Py_INCREF(r);
return r; return r;
@@ -1492,7 +1497,11 @@ OptionsItem(OptionsObject *self, PyObject *keyObject)
else if (flags & SOPT_STRING) else if (flags & SOPT_STRING)
{ {
if (stringval) if (stringval)
return PyBytes_FromString((char *) stringval); {
PyObject *r = PyBytes_FromString((char *) stringval);
vim_free(stringval);
return r;
}
else else
{ {
PyErr_SetString(PyExc_RuntimeError, PyErr_SetString(PyExc_RuntimeError,
@@ -1516,9 +1525,9 @@ set_option_value_for(key, numval, stringval, opt_flags, opt_type, from)
int opt_type; int opt_type;
void *from; void *from;
{ {
win_T *save_curwin; win_T *save_curwin = NULL;
tabpage_T *save_curtab; tabpage_T *save_curtab = NULL;
buf_T *save_curbuf; buf_T *save_curbuf = NULL;
VimTryStart(); VimTryStart();
switch (opt_type) switch (opt_type)

View File

@@ -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 */
/**/
1002,
/**/ /**/
1001, 1001,
/**/ /**/