summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-03-19 22:22:55 +0100
committerBram Moolenaar <Bram@vim.org>2019-03-19 22:22:55 +0100
commit8e9a24a127c4ef8833fdc3986623f96c7d04210f (patch)
treed1aee2626ace3749ccbac2766ee158037b43bf2a
parent828bff1f9b4847da79abd7a97ddc48687e257d6c (diff)
downloadvim-git-8e9a24a127c4ef8833fdc3986623f96c7d04210f.tar.gz
patch 8.1.1021: pyeval() and py3eval() leak memoryv8.1.1021
Problem: pyeval() and py3eval() leak memory. Solution: Do not increase the reference count twice. (Ozaki Kiichi, closes #4129)
-rw-r--r--src/if_python.c24
-rw-r--r--src/if_python3.c24
-rw-r--r--src/version.c2
3 files changed, 12 insertions, 38 deletions
diff --git a/src/if_python.c b/src/if_python.c
index c0a3fe105..9f9c257ee 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -1555,30 +1555,16 @@ FunctionGetattr(PyObject *self, char *name)
}
void
-do_pyeval (char_u *str, typval_T *rettv)
+do_pyeval(char_u *str, typval_T *rettv)
{
DoPyCommand((char *) str,
(rangeinitializer) init_range_eval,
(runner) run_eval,
(void *) rettv);
- switch (rettv->v_type)
+ if (rettv->v_type == VAR_UNKNOWN)
{
- case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break;
- case VAR_LIST: ++rettv->vval.v_list->lv_refcount; break;
- case VAR_FUNC: func_ref(rettv->vval.v_string); break;
- case VAR_PARTIAL: ++rettv->vval.v_partial->pt_refcount; break;
- case VAR_UNKNOWN:
- rettv->v_type = VAR_NUMBER;
- rettv->vval.v_number = 0;
- break;
- case VAR_NUMBER:
- case VAR_STRING:
- case VAR_FLOAT:
- case VAR_SPECIAL:
- case VAR_JOB:
- case VAR_CHANNEL:
- case VAR_BLOB:
- break;
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = 0;
}
}
@@ -1594,7 +1580,7 @@ Py_GetProgramName(void)
#endif /* Python 1.4 */
int
-set_ref_in_python (int copyID)
+set_ref_in_python(int copyID)
{
return set_ref_in_py(copyID);
}
diff --git a/src/if_python3.c b/src/if_python3.c
index 8b1b5beb6..e8ab44f3b 100644
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -1663,35 +1663,21 @@ LineToString(const char *str)
}
void
-do_py3eval (char_u *str, typval_T *rettv)
+do_py3eval(char_u *str, typval_T *rettv)
{
DoPyCommand((char *) str,
(rangeinitializer) init_range_eval,
(runner) run_eval,
(void *) rettv);
- switch(rettv->v_type)
+ if (rettv->v_type == VAR_UNKNOWN)
{
- case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break;
- case VAR_LIST: ++rettv->vval.v_list->lv_refcount; break;
- case VAR_FUNC: func_ref(rettv->vval.v_string); break;
- case VAR_PARTIAL: ++rettv->vval.v_partial->pt_refcount; break;
- case VAR_UNKNOWN:
- rettv->v_type = VAR_NUMBER;
- rettv->vval.v_number = 0;
- break;
- case VAR_NUMBER:
- case VAR_STRING:
- case VAR_FLOAT:
- case VAR_SPECIAL:
- case VAR_JOB:
- case VAR_CHANNEL:
- case VAR_BLOB:
- break;
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = 0;
}
}
int
-set_ref_in_python3 (int copyID)
+set_ref_in_python3(int copyID)
{
return set_ref_in_py(copyID);
}
diff --git a/src/version.c b/src/version.c
index c336046bf..bd02fa5bd 100644
--- a/src/version.c
+++ b/src/version.c
@@ -780,6 +780,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1021,
+/**/
1020,
/**/
1019,