comparison src/if_python.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 a83c4b1f8ea2
children f0f9692d4487
comparison
equal deleted inserted replaced
16031:10f5ef57e3e4 16032:831f9e74eded
1553 else 1553 else
1554 return Py_FindMethod(FunctionMethods, self, name); 1554 return Py_FindMethod(FunctionMethods, self, name);
1555 } 1555 }
1556 1556
1557 void 1557 void
1558 do_pyeval (char_u *str, typval_T *rettv) 1558 do_pyeval(char_u *str, typval_T *rettv)
1559 { 1559 {
1560 DoPyCommand((char *) str, 1560 DoPyCommand((char *) str,
1561 (rangeinitializer) init_range_eval, 1561 (rangeinitializer) init_range_eval,
1562 (runner) run_eval, 1562 (runner) run_eval,
1563 (void *) rettv); 1563 (void *) rettv);
1564 switch (rettv->v_type) 1564 if (rettv->v_type == VAR_UNKNOWN)
1565 { 1565 {
1566 case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break; 1566 rettv->v_type = VAR_NUMBER;
1567 case VAR_LIST: ++rettv->vval.v_list->lv_refcount; break; 1567 rettv->vval.v_number = 0;
1568 case VAR_FUNC: func_ref(rettv->vval.v_string); break;
1569 case VAR_PARTIAL: ++rettv->vval.v_partial->pt_refcount; break;
1570 case VAR_UNKNOWN:
1571 rettv->v_type = VAR_NUMBER;
1572 rettv->vval.v_number = 0;
1573 break;
1574 case VAR_NUMBER:
1575 case VAR_STRING:
1576 case VAR_FLOAT:
1577 case VAR_SPECIAL:
1578 case VAR_JOB:
1579 case VAR_CHANNEL:
1580 case VAR_BLOB:
1581 break;
1582 } 1568 }
1583 } 1569 }
1584 1570
1585 /* Don't generate a prototype for the next function, it generates an error on 1571 /* Don't generate a prototype for the next function, it generates an error on
1586 * newer Python versions. */ 1572 * newer Python versions. */
1592 return "vim"; 1578 return "vim";
1593 } 1579 }
1594 #endif /* Python 1.4 */ 1580 #endif /* Python 1.4 */
1595 1581
1596 int 1582 int
1597 set_ref_in_python (int copyID) 1583 set_ref_in_python(int copyID)
1598 { 1584 {
1599 return set_ref_in_py(copyID); 1585 return set_ref_in_py(copyID);
1600 } 1586 }