comparison src/if_python3.c @ 16032:831f9e74eded v8.1.1021

patch 8.1.1021: pyeval() and py3eval() leak memory commit https://github.com/vim/vim/commit/8e9a24a127c4ef8833fdc3986623f96c7d04210f Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 19 22:22:55 2019 +0100 patch 8.1.1021: pyeval() and py3eval() leak memory Problem: pyeval() and py3eval() leak memory. Solution: Do not increase the reference count twice. (Ozaki Kiichi, closes #4129)
author Bram Moolenaar <Bram@vim.org>
date Tue, 19 Mar 2019 22:30:05 +0100
parents 6694659c6ad6
children cd5c83115ec6
comparison
equal deleted inserted replaced
16031:10f5ef57e3e4 16032:831f9e74eded
1661 vim_free(tmp); 1661 vim_free(tmp);
1662 return result; 1662 return result;
1663 } 1663 }
1664 1664
1665 void 1665 void
1666 do_py3eval (char_u *str, typval_T *rettv) 1666 do_py3eval(char_u *str, typval_T *rettv)
1667 { 1667 {
1668 DoPyCommand((char *) str, 1668 DoPyCommand((char *) str,
1669 (rangeinitializer) init_range_eval, 1669 (rangeinitializer) init_range_eval,
1670 (runner) run_eval, 1670 (runner) run_eval,
1671 (void *) rettv); 1671 (void *) rettv);
1672 switch(rettv->v_type) 1672 if (rettv->v_type == VAR_UNKNOWN)
1673 { 1673 {
1674 case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break; 1674 rettv->v_type = VAR_NUMBER;
1675 case VAR_LIST: ++rettv->vval.v_list->lv_refcount; break; 1675 rettv->vval.v_number = 0;
1676 case VAR_FUNC: func_ref(rettv->vval.v_string); break;
1677 case VAR_PARTIAL: ++rettv->vval.v_partial->pt_refcount; break;
1678 case VAR_UNKNOWN:
1679 rettv->v_type = VAR_NUMBER;
1680 rettv->vval.v_number = 0;
1681 break;
1682 case VAR_NUMBER:
1683 case VAR_STRING:
1684 case VAR_FLOAT:
1685 case VAR_SPECIAL:
1686 case VAR_JOB:
1687 case VAR_CHANNEL:
1688 case VAR_BLOB:
1689 break;
1690 } 1676 }
1691 } 1677 }
1692 1678
1693 int 1679 int
1694 set_ref_in_python3 (int copyID) 1680 set_ref_in_python3(int copyID)
1695 { 1681 {
1696 return set_ref_in_py(copyID); 1682 return set_ref_in_py(copyID);
1697 } 1683 }